[pmwiki-devel] Some changes to pmwiki.php that help diagnose php7.2 problems

Petko Yotov 5ko at 5ko.fr
Mon Dec 4 11:45:32 CST 2017


Thanks Chuck for your contributions.

On 02/12/2017 05:26, Chuck Goldstein wrote:
> My Web host, 1and1, is running PHP Version 7.2.0RC6. I've updated
> pmwiki.php to cause fewer "deprecated" warnings about Cookbook
> recipes, and to provide some diagnostic information. Please see the
> attached patch "pmwiki-cg.diff".
> 
> 
> The first hunk defines two new functions:
> 
> 1. PCF($args, $code) is a replacement for PHP's create_function(). It
> creates a lambda function. When enabled by setting $EnablePCF to a
> true value in a config file, it uses PHP eval() to create the
> function. If not enabled, it uses create_function().

I am not very comfortable adding a feature relying on `eval()` because 
of the security risks and I suspect it will be the next PHP feature to 
become deprecated.

But your implementation is very good. Let me think about either adding 
it or at least allowing a way for it to be hooked.

> 2. PCFWarn() is a utility function used by PCF and the modified PCCF.
> When enabled by setting $EnablePCFWarn to a true value in a config
> file, it adds an entry to the $MessagesFmt array describing the
> function which was called (Markup_e, PPRE, PCCF or PCF), the name of
> the file containing the call, the line number in the file and whether
> a function had to be created.

The entry can probably be added with StopWatch() instead of 
$MessagesFmt. The former only appears when the diagnostic tools are 
enabled, the latter may output messages at the top or middle of the 
page, eg from a recipe like PmForm or Thumblist.

> It also modifies PCCF to call PCF instead of create_function and to
> call PCFWarn if it gets the lambda from its cache array,
> $CallbackFunctions.
> 
> 
> The second hunk modifies the Markup and Markup_e functions so that, if
> enabled by setting $EnableMarkupDiag to a true value in a config file,
> the caller's file name, line number and pattern are saved in the
> markup table for every call, not just those using the deprecated "e"
> flag. This makes the ruleset and ruletable actions very instructive.

This also looks good, I'll add such a switch.

Thanks!
Petko



More information about the pmwiki-devel mailing list