Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Juergen-aus-Zuendorf opened this issue Nov 3, 2022 · 0 comments

Comments

@Juergen-aus-Zuendorf
Copy link

Juergen-aus-Zuendorf commented Nov 3, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant