[pmwiki-users] Recipes you use/need to be updated for PHP 5.5
John Rankin
john.rankin at affinity.co.nz
Tue Jan 7 16:48:46 CST 2014
On 5/01/14 11:46 PM, Petko Yotov wrote:
> John Rankin writes:
> ...
>> Any advice on whether I should use global variables or the object-method
>> to pass variables to the callback function? The code I'm looking at uses
>> preg_replace with /e a lot, and I'm a little reluctant to use global
>> variables to pass parameters.
>
> I am reluctant too to use global variables, but that's a single global
> variable - array - holding the local variables.
>
> Classes and callbacks have changes in different PHP versions so it may
> be tricky to write one that is compatible with PHP 4.2 to 5.5. But not
> impossible.
I'd like to ask a follow-up about using preg_replace_callback with the
anonymous functions capability (closures) provided from php 5.3 onwards;
for example:
function ($match) use ($pagename) { ... }
While I understand the rationale for supporting older versions of php,
is this necessarily the best strategy?
Mac OS X Leopard (10.5) on my PowerPC mac runs php 5.2. Snow Leopard
(10.6) runs php 5.3. Presumably Lion, Mountain Lion and Mavericks run
later php versions. Ubuntu 12.04 LTS runs php 5.3 and I think 14.04 LTS
will ship with php 5.5.
I wonder whether consideration should be given to renaming pmwiki 2.2.56
as pmwiki 2.5.1, with a requirement that it depends on php 5.3 or above.
Those running an older version of php would need to run 2.2.55 or below.
Similarly, existing cookbook recipes would continue to work with php 5.4
or below, but new versions which are compatible with php 5.5 and above
could be progressively added.
I can see arguments for and against this approach, but in my case access
to the 'use' keyword to pass parameters is very attractive. Php 5.2 has
not been officially supported since 2011-01-06 and php 5.3 was released
in 2009-06-30 with support until 2014-07.
Thoughts? Any idea what proportion of installations are running pmwiki
on php 5.2 or below? Any idea how many of these are planning to upgrade
to pmwiki 2.2.56 or above?
JR
--
John Rankin
Affinity Limited
T +64 4 495 3737
M +64 21 726 546
More information about the pmwiki-users
mailing list