[SAC] [OSGeo] #174: View php source code in trac repository browser

#174: View php source code in trac repository browser
--------------------+-------------------------------------------------------
Reporter: mschulz | Owner: sac@lists.osgeo.org
    Type: task | Status: new
Priority: normal | Component: SAC
Keywords: |
--------------------+-------------------------------------------------------
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.

--
Ticket URL: <http://trac.osgeo.org/osgeo/ticket/174&gt;
OSGeo <http://www.osgeo.org/&gt;
OSGeo committee and general foundation issue tracker.

#174: View php source code in trac repository browser
----------------------+-----------------------------------------------------
  Reporter: mschulz | Owner: sac@lists.osgeo.org
      Type: task | Status: new
  Priority: normal | Component: SAC
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by jbirch):

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.

--
Ticket URL: <http://trac.osgeo.org/osgeo/ticket/174#comment:1&gt;
OSGeo <http://www.osgeo.org/&gt;
OSGeo committee and general foundation issue tracker.

#174: View php source code in trac repository browser
----------------------+-----------------------------------------------------
  Reporter: mschulz | Owner: sac@lists.osgeo.org
      Type: task | Status: new
  Priority: normal | Component: SAC
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by warmerdam):

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.

--
Ticket URL: <http://trac.osgeo.org/osgeo/ticket/174#comment:2&gt;
OSGeo <http://www.osgeo.org/&gt;
OSGeo committee and general foundation issue tracker.

#174: View php source code in trac repository browser
----------------------+-----------------------------------------------------
  Reporter: mschulz | Owner: sac@lists.osgeo.org
      Type: task | Status: new
  Priority: normal | Component: SAC
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by mschulz):

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

--
Ticket URL: <http://trac.osgeo.org/osgeo/ticket/174#comment:3&gt;
OSGeo <http://www.osgeo.org/&gt;
OSGeo committee and general foundation issue tracker.

#174: View php source code in trac repository browser
----------------------+-----------------------------------------------------
  Reporter: mschulz | Owner: sac@lists.osgeo.org
      Type: task | Status: new
  Priority: normal | Component: SAC
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by warmerdam):

{{{
[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.

--
Ticket URL: <http://trac.osgeo.org/osgeo/ticket/174#comment:4&gt;
OSGeo <http://www.osgeo.org/&gt;
OSGeo committee and general foundation issue tracker.

#174: View php source code in trac repository browser
----------------------+-----------------------------------------------------
  Reporter: mschulz | Owner: sac@lists.osgeo.org
      Type: task | Status: new
  Priority: normal | Component: SAC
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by mschulz):

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.

--
Ticket URL: <http://trac.osgeo.org/osgeo/ticket/174#comment:5&gt;
OSGeo <http://www.osgeo.org/&gt;
OSGeo committee and general foundation issue tracker.

#174: View php source code in trac repository browser
----------------------+-----------------------------------------------------
  Reporter: mschulz | Owner: sac@lists.osgeo.org
      Type: task | Status: new
  Priority: normal | Component: SAC
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by warmerdam):

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?

--
Ticket URL: <http://trac.osgeo.org/osgeo/ticket/174#comment:6&gt;
OSGeo <http://www.osgeo.org/&gt;
OSGeo committee and general foundation issue tracker.