gturri / nspages

Plugin for dokuwiki - Display tables of content
http://www.dokuwiki.org/plugin:nspages
GNU General Public License v2.0
25 stars 24 forks source link

Warnings: optionParser.php and printer.php #137

Closed nerun closed 1 year ago

nerun commented 1 year ago

I am receiving this warning:

PHP Warning:  Undefined array key 0 in .../wiki/lib/plugins/nspages/optionParser.php on line 139
PHP Warning:  Trying to access array offset on value of type null in .../wiki/lib/plugins/nspages/printers/printer.php on line 115

This is the page in my wiki generating these issues: RPG Livre - Wiki: Projetos.

Here my settings: settings

Here the code i am using:

<nspages -tree -r -h1 -textNs="" -textPages="" -exclude>

My PHP version is 8.1.

gturri commented 1 year ago

thanks for this bug report. Could you please let me know which version of the plugin you are using? (you should see it at https://www.gurpzine.com.br/wiki/doku.php?do=admin&page=extension ; click on the arrow which points at the bottom to reveal the version) image

nerun commented 1 year ago

2022-11-24

gturri commented 1 year ago

Thanks.

I think the issue is that PHP8 is stricter than PHP7 and that I'm currently only testing against PHP7...

I think I understand where the first warning you mention comes from. I hope I should be able to fix it in a couple of days. I'll look into the other one afterwards. Meanwhile, if you stumble on other similar warning, please report them as well.

nerun commented 1 year ago

FIX for printer.php on line 115

Find this at line 115

if($item['type'] !== 'd') {

Change to this:

if(isset($item) && $item['type'] !== 'd') {

FIX for optionParser.php on line 139

Find at line 139:

$match = optionParser::_removeFromMatch($found[0], $match);

Change to:

if(sizeof($found) > 0) {
    $match = optionParser::_removeFromMatch($found[0], $match);
}
nerun commented 1 year ago

It's solved for me, you can close it whenever you want.

gturri commented 1 year ago

Thanks for this heads up!

It turns out that, thanks to your bug report, I noticed other PHP warnings. They are fixed with https://github.com/gturri/nspages/commit/5b8488d9bea5c6cca934c2b1a8b6423cace329a4 . I encourage you to update nspages in order to benefit from all those fixes.