Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#174 closed task (fixed)

View php source code in trac repository browser

Reported by: mschulz Owned by: warmerdam
Priority: normal Milestone:
Component: SysAdmin Keywords: jbirch
Cc:

Description

At the moment php source code (actually source code of files with .php extension) from the mapbender project cannot be displayed in tracs repository browser. Maybe the mixture of javascript/php code is a problem to determine correct language for syntax highlighting. Frank W. suggested they should be displayed as plain text. mapserver/mapscript/php3/examples/*.phtml can be viewed, but no syntax highlighting.

Change History (11)

comment:1 by jbirch, 16 years ago

Trac contains a PHP syntax highlighter; it would be nice to be able to use it:

http://trac.edgewall.org/browser/tags/trac-0.10.4/trac/mimeview/php.py

For this to work, I believe (from reading a couple tickets) that you have to set the path to the php CLI (or for older builds the php CGI with a "-q" switch) in the trac.ini file:

[mimeviewer] php_path = /path/to/php

If this works, I'd love to see the same change made to the MapGuide Trac.

comment:2 by warmerdam, 16 years ago

I have been unable to work out the problem. I set php_path in the Mapbender config file, and that didn't seem to matter. In any event we aren't getting an error about php.

I tried modifying mimeviewer/api.py to treat .php as text/plain, but that did not seem to have any effect either. Perhaps it is getting the mimetype from elsewhere?

At this point I'm stumped and leaving this issue for someone with more savvy.

comment:3 by mschulz, 16 years ago

Just something i found while searching through various trac-threads with similar topic (but they all have errors in the log though):

In this case, php (correctly configured path) could not be loaded because module simplexml could not be loaded. This error could be reproduced from the commandline with:

/path_to/bin/php -sn

comment:4 by warmerdam, 16 years ago

[warmerdam@osgeo1 ~]$ /usr/bin/php -sn
Content-type: text/html
X-Powered-By: PHP/4.3.9

<code><font color="#000000">

It seems to work fine. I'm not convinced that Trac is even trying to invoke the php processing.

comment:5 by mschulz, 16 years ago

Is logging enabled in this trac.ini? If not and you add logging, apache must be restartet for logging to work. Frank, could you invoke "/usr/bin/php --version"? This should tell whether the php used is the cgi or the cli.

comment:6 by warmerdam, 16 years ago

Good idea on the logging:

2007-11-28 10:07:21,054 Trac[api] WARNING: HTML preview using <trac.mimeview.php.PHPRenderer object at 0xb6e049ec> failed (You appear to be using the PHP CGI binary. Trac requires the CLI version for syntax highlighting.)
Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/trac/mimeview/api.py", line 456, in render
    return Markup(self._annotate(result, annotations))
  File "/usr/lib/python2.3/site-packages/trac/mimeview/api.py", line 490, in _annotate
    for num, line in enumerate(_html_splitlines(lines)):
  File "/usr/lib/python2.3/site-packages/trac/mimeview/api.py", line 620, in _html_splitlines
    for line in lines:
  File "/usr/lib/python2.3/site-packages/trac/mimeview/php.py", line 94, in render
    raise TracError('You appear to be using the PHP CGI '
TracError: You appear to be using the PHP CGI binary. Trac requires the CLI version for syntax highlighting.

Also php --version reports:

[root@osgeo1 log]# /usr/bin/php --version
PHP 4.3.9 (cgi) (built: Sep 19 2007 05:43:52)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

do you have any suggestion about how to get a non-cgi version of php?

comment:7 by warmerdam, 16 years ago

Owner: changed from sac@… to warmerdam

Taking ticket since it just occured to me all this chatter is going to all of the SAC list.

comment:8 by jbirch, 16 years ago

I believe that at version 4 you had to call the php executable with a "-q" option (that's a Q for Quiet) to get command-line mode; there was no separate CLI binary. Could be wrong though.

comment:9 by mschulz, 16 years ago

I normally use a source distribution, after building, there are the corresponding directories under /php-source-dir/sapi/cli/ and .../cgi/. Usually, the cli version installs at bindir/php and the cgi as bindir/php-cgi. I've just checked and there is a cli version in php 4.3.10.

comment:10 by warmerdam, 16 years ago

Keywords: jbirch added
Resolution: fixed
Status: newclosed

I have prepared a wrapper script that runs php with the -q flag, and put it at:

/var/www/trac/php_cmd.sh

I have reconfigured trac.ini to reference it. Now the following works!

http://trac.osgeo.org/mapbender/browser/trunk/mapbender/http/php/database-pgsql.php

I have also updated the mapguide trac to use the same script. Could you confirm it works Jason?

comment:11 by mschulz, 16 years ago

Thanks Frank. That is really an improvement.

Note: See TracTickets for help on using tickets.