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

0 views
Skip to first unread message

V.Krishn

unread,
Jan 19, 2023, 10:35:53 AM1/19/23
to PmWiki Devel Mailing List

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.

--
Regards,
V.Krishn

_______________________________________________
pmwiki-devel mailing list
pmwiki...@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

Petko Yotov

unread,
Jan 19, 2023, 12:35:39 PM1/19/23
to vkri...@gmail.com, PmWiki Devel Mailing List
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.

V.Krishn

unread,
Jan 19, 2023, 1:15:11 PM1/19/23
to Petko Yotov, PmWiki Devel Mailing List
On 1/19/23 23:04, Petko Yotov wrote:
> 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.

Thanks,

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

I have fixed few more undefined vars and seems fixed.
Currently all recipes works in php7.x.

For bugs in PHP 8.x, would try to wait for newer released PmWiki,
or test in latest one in 2.3.x series.

--
Regards,
V.Krishn
Reply all
Reply to author
Forward
0 new messages