samuelet / indexmenu

A dokuwiki plugin to show a customizable and sortable index for a namespace.
http://dokuwiki.org/plugin:indexmenu
GNU General Public License v2.0
44 stars 42 forks source link

E_WARNING: Undefined array key "userinfo" #278

Closed nerun closed 7 months ago

nerun commented 7 months ago

This is the same issue as #247, closed. Apparently it was fixed by the already merged PR #134. But the changes made by that PR were partially undone. Now i receive TONS of warnings, ALL them related to this single issue:

******
[Log file too large. Previous lines skipped!]

E_WARNING: Undefined array key "userinfo"
.../lib/plugins/indexmenu/action.php(71)

I will submit a PR to change action.php line 71 from:

$JSINFO['isauth'] = (int) $INFO['userinfo'];

Back to the same as PR #134:

$JSINFO['isauth'] = isset($INFO['userinfo']) ? (int) $INFO['userinfo'] : 0;
Klap-in commented 7 months ago

Thanks for reporting again. Why does (int)$INFO['userinfo'] ?? 0; not work, probably because casting to (int) is performed before the null coalescing operator ???

nerun commented 7 months ago

No idea. I have tested both in PHP Sandbox and DokuWiki and the previous way is the only one.

My code in PHP sandbox, just for testing:

<?php
//$INFO = array('userinfo' => 3);
//$INFO = array('userinfo' => null);
$INFO = array();

//$JSINFO['isauth'] = (int)$INFO['userinfo'] ?? 0;
$JSINFO['isauth'] = isset($INFO['userinfo']) ? (int) $INFO['userinfo'] : 0;

print_r($JSINFO);
Klap-in commented 7 months ago

Merged, thanks!