Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-08-04 06:55:18

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Show svnversion in txp:php or txp:variable

D’oh! Nice catch, Matt.

Offline

#14 2009-08-04 16:35:00

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: Show svnversion in txp:php or txp:variable

jm wrote:

Weird. What about trying shell_exec("/usr/bin/svnversion");?

No output.

Also, what version of PHP are you running on your devel-server? Leopard’s default?

I’m using 5.2.6, on MAMP 1.7.2.

MattD wrote:

If invoked on a directory that is not a working copy, svnversion assumes it is an exported working copy and prints "exported"

Hmm. Putting the absolute path as an argument in the command works in the Terminal:

/usr/bin/svnversion . /Users/.../sites/example.dev

But not in php:

php -r 'shell_exec("/usr/bin/svnversion . /Users/.../sites/example.dev");'

Offline

#15 2009-08-04 16:42:32

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,454
Website GitHub

Re: Show svnversion in txp:php or txp:variable

My guess is that the dot is interpreted as “the PHP environment” (htdocs?) which could well account for the ‘exported’ output. Can you not use

"/usr/bin/svnversion /Users/.../sites/example.dev"

like that, directly? (I’ve never used the command, just speculating)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#16 2009-08-06 17:03:57

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: Show svnversion in txp:php or txp:variable

Should have turned on Textpattern’s debugging production status.

If I enter this in the terminal within the project directory:

php -r "echo exec(svnversion);"

I get the correct version info.

When I enter this in my template:

<txp:php>echo exec(svnversion);</txp:php>

I get this:

Tag error: <txp:php> ->  Notice: Use of undefined constant svnversion - assumed 'svnversion'  on line 1
textpattern/publish/taghandlers.php:3082 eval()
textpattern/publish.php:1090 php()
textpattern/publish.php:1025 processTags()
textpattern/lib/txplib_misc.php:909 parse()
textpattern/publish.php:1090 splat()
textpattern/publish.php:1012 processTags()
textpattern/lib/txplib_misc.php:1540 parse()
textpattern/publish/taghandlers.php:246 parse_form()
textpattern/publish.php:1090 output_form()
textpattern/publish.php:1012 processTags()

Entering the absolute path to svnversion results in a more terse debug message:

Parse error: syntax error, unexpected '/', expecting ')' in /path/to/textpattern/publish/taghandlers.php(3082) : eval()'d code on line 1

I should stop messing around with this! ;)

Offline

#17 2009-08-06 17:51:16

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Show svnversion in txp:php or txp:variable

johnstephens wrote:

Tag error: <txp:php> -> Notice: Use of undefined constant svnversion – assumed ‘svnversion’ on line 1

You must quote svnversion (string, not constant or function).

Offline

Board footer

Powered by FluxBB