[pmwiki-devel] undefined array in $FmtPV[$var]

Petko Yotov 5ko at 5ko.fr
Thu Jan 19 09:34:52 PST 2023


What is your code that defines your custom page variable?

It looks like an array that is expected to have the keys "qnp" and "qn" 
but they don't exist.

If you have a complex evaluation, my advice is to write a new function 
and define it in the $FmtPV array. It will be simpler, cleaner, safer 
and easier to debug.

Something like this:

   $FmtPV['$MyVar'] = 'FmtMyVar($pagename, $pn, $group, $name, $page, 
$var)';

The arguments are optional; use those that make sense to you:

  - $pagename is normally the full name of the browsed page
  - $pn is the full current page name, or another page name
    if you request {OtherPage$MyVar} or {=$MyVar}
  - $group and $name are obvious, based on $pn
  - $page is an array containing the latest metadata
    of the page, without page text or history.
    For example $page['title'] is the title of $pn.
  - $var is the variable name, here '$MyVar' (you can
    define several variables calling the same function).

Petko

P.S. If you're using PHP 8, we've been working the whole year to update 
the core for the breaking changes PHP 8 introduced. So many warnings in 
2.2.145 will not appear in the latest version.

On 19/01/2023 16:31, V.Krishn wrote:
> ERROR:
> 2023/01/19 19:59:41 [error] 25181#25181: *904 FastCGI sent in stderr:
> "PHP message:
> PHP Warning:  Undefined array key "qnp" in
> /tmp/pmwiki/2.2.145/pmwiki.php(1005) : eval()'d code on line 1PHP
> message:
> PHP Warning:  Undefined array key "qn" in
> /tmp/pmwiki/2.2.145/pmwiki.php(1005) : eval()'d code on line 1" while
> reading response header from upstream,
> 
> TEST-BED:
> Pmwiki Version: 2.2.145
> Server: nginx-1.22.0
> Php: php-fpm-8.0.19
> Os: AlpineLinux(v3.16)
> 
> NOTE:
> Above error is from "function PageVar()" and can currently be
> suppressed by changing the line from (not quite sure about it though),
> 
> if (@$FmtPV[$var]) return eval("return ({$FmtPV[$var]});");
> TO
> if (@$FmtPV[$var]) return @eval("return ({$FmtPV[$var]});");
> 
> Same issue with PmWiki-2.3.13 (line 1193).
> Still trying to figure out if error can be fixed from my code.
> 
> Any suggestion appreciated.



More information about the pmwiki-devel mailing list