Klap-in / dokuwiki-plugin-imagereference

Dokuwiki plugin that creates references to images/tables in your text, like the LaTeX figure references.
https://www.dokuwiki.org/plugin:imagereference
0 stars 7 forks source link

TypeError: array_search(): Argument #2 ($haystack) must be of type array, null given #37

Open Juergen-aus-Zuendorf opened 2 years ago

Juergen-aus-Zuendorf commented 2 years ago

Hi,

in some constellations I get the following errormessage:

TypeError: array_search(): Argument #2 ($haystack) must be of type array, null given
An unforeseen error has occured. This is most likely a bug somewhere. It might be a problem in the imagereference plugin.

More info has been written to the DokuWiki error log.

The log file says this:

2022-11-03 15:03:41
TypeError: array_search(): Argument #2 ($haystack) must be of type array, null given
/var/www/html/wiki/lib/plugins/imagereference/syntax/imgcaption.php(151)
#0 /var/www/html/wiki/lib/plugins/imagereference/syntax/imgcaption.php(151): array_search('b20190813-14201...', NULL)
#1 /var/www/html/wiki/inc/parser/renderer.php(117): syntax_plugin_imagereference_imgcaption->render('xhtml', Object(Doku_Renderer_xhtml), Array)
#2 /var/www/html/wiki/inc/parser/renderer.php(131): Doku_Renderer->plugin('imagereference_...', Array, 4, '</imgcaption>')
#3 /var/www/html/wiki/lib/plugins/include/syntax/include.php(157): Doku_Renderer->nest(Array)
#4 /var/www/html/wiki/inc/parser/renderer.php(117): syntax_plugin_include_include->render('xhtml', Object(Doku_Renderer_xhtml), Array)
#5 /var/www/html/wiki/inc/parserutils.php(682): Doku_Renderer->plugin('include_include', Array, 5, '{{page>redaktio...')
#6 /var/www/html/wiki/inc/Ui/PageView.php(56): p_render('xhtml', Array, NULL)
#7 /var/www/html/wiki/inc/Action/Preview.php(29): dokuwiki\Ui\PageView->show()
#8 /var/www/html/wiki/inc/template.php(100): dokuwiki\Action\Preview->tplContent()
#9 [internal function]: tpl_content_core('preview')
#10 /var/www/html/wiki/inc/Extension/Event.php(133): call_user_func_array('tpl_content_cor...', Array)
#11 /var/www/html/wiki/inc/Extension/Event.php(199): dokuwiki\Extension\Event->trigger('tpl_content_cor...', true)
#12 /var/www/html/wiki/inc/template.php(85): dokuwiki\Extension\Event::createAndTrigger('TPL_ACT_RENDER', 'preview', 'tpl_content_cor...')
#13 /var/www/html/wiki/lib/tpl/bootstrap3/main.php(117): tpl_content(false)
#14 /var/www/html/wiki/inc/actions.php(27): include('/var/www/html/w...')
#15 /var/www/html/wiki/doku.php(126): act_dispatch()
#16 {main}

If I open a page with the imagereference syntax inside itself, everything is ok. But if I use the include plugin and reference to the page with the imagereference syntax I get the error message.

My workaround at the moment was to modify the file imgcaption.php from line 151 down:

// Workaround nach PHP-Update:
if ($caprefs <> NULL) {
    $data['refnumber'] = array_search($data['caprefname'], $caprefs);
}

Perhaps the problem occurred after updating our server to PHP version 8.1.11 some days ago.

What can I do?

Best regards Juergen