lpaulsen93 / dokuwiki_note

DokuWiki plugin which displays boxes with four kinds of design for each note-type
http://www.dokuwiki.org/plugin:note
GNU General Public License v2.0
5 stars 6 forks source link

PHP 8 Warning: Undefined array key #22

Open arlt opened 1 year ago

arlt commented 1 year ago

The following warning appears with the example and PHP 8.1.11:

[Thu Oct 13 11:46:36.623754 2022] [proxy_fcgi:error] [pid 29956] [client 127.0.0.1:45224] AH01071: Got error 'PHP message: PHP Warning:  Undefined array key 1 in /var/www/dokuwiki/lib/plugins/note/syntax.php on line 103'

Example code:

<note>
This is my note ! Remember it!!
</note>

Version information:

$ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
$ php --version
PHP 8.1.11 (cli) (built: Sep 28 2022 09:08:05) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.11, Copyright (c) Zend Technologies
$ cat dokuwiki/VERSION 
2022-07-31a "Igor"
$ grep date dokuwiki/lib/plugins/note/plugin.info.txt 
date   2020-06-28

Maybe this will help: https://github.com/splitbrain/dokuwiki/pull/3754 (how to fix explode/list constructs)

darxmurf commented 1 year ago

I have no idea of how this works but after a quick look, there is a loop somewhere when a note is found on a page. This loop generates 3 entries per notes

Array ( [0] => 1 [1] => noteclassic ) Array ( [0] => 3 [1] => test ) Array ( [0] => 4 )

If I understand correctly, one entry for the opening note tag, one entry for the text and one for the closing tag. We can see the 3rd one doesn't have a [1] index which causes the issue.

For now, I did a pretty dirty fix to avoid this error and inserted

if (!isset($indata[1])) { $indata[1] = ""; }

just before the line 103 in syntax.php

So, the code looks like

function render($mode, Doku_Renderer $renderer, $indata) { if ($mode == 'xhtml') { if (!isset($indata[1])) { $indata[1] = ""; } list($state, $data) = $indata;

rogueRPI commented 1 year ago

Same problem here, and the above fixed it for me!

PHP 8.2.4 on IIS, DokuWiki 2023-04-04a "Jack Jackrum"

technikamateur commented 1 year ago

I'm also affected.

Mara01010011 commented 1 year ago

Same here and fixed it with the changes as darxmurf suggested.

asheenlevrai commented 5 months ago

Anyone knows if the fork from Thomas Schäfer fixes these issues?