Page MenuHomePhabricator

[subtask] PHP Warning: preg_match() expects parameter 2 to be string, array given (in Vector Hooks::shouldDisableMaxWidth)
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Warning: preg_match() expects parameter 2 to be string, array given
exception.trace
from /srv/mediawiki/php-1.40.0-wmf.6/skins/Vector/includes/Hooks.php(829)
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.40.0-wmf.6/skins/Vector/includes/Hooks.php(829): preg_match(string, array)
#2 /srv/mediawiki/php-1.40.0-wmf.6/skins/Vector/includes/Hooks.php(729): MediaWiki\Skins\Vector\Hooks::shouldDisableMaxWidth(array, Title, array)
#3 /srv/mediawiki/php-1.40.0-wmf.6/includes/HookContainer/HookContainer.php(160): MediaWiki\Skins\Vector\Hooks->onOutputPageBodyAttributes(OutputPage, MediaWiki\Skins\Vector\SkinVector22, array)
#4 /srv/mediawiki/php-1.40.0-wmf.6/includes/HookContainer/HookRunner.php(2711): MediaWiki\HookContainer\HookContainer->run(string, array, array)
#5 /srv/mediawiki/php-1.40.0-wmf.6/includes/OutputPage.php(3436): MediaWiki\HookContainer\HookRunner->onOutputPageBodyAttributes(OutputPage, MediaWiki\Skins\Vector\SkinVector22, array)
#6 /srv/mediawiki/php-1.40.0-wmf.6/includes/skins/SkinMustache.php(63): OutputPage->headElement(MediaWiki\Skins\Vector\SkinVector22)
#7 /srv/mediawiki/php-1.40.0-wmf.6/includes/skins/SkinTemplate.php(177): SkinMustache->generateHTML()
#8 /srv/mediawiki/php-1.40.0-wmf.6/includes/OutputPage.php(2892): SkinTemplate->outputPage()
#9 /srv/mediawiki/php-1.40.0-wmf.6/includes/MediaWiki.php(922): OutputPage->output(boolean)
#10 /srv/mediawiki/php-1.40.0-wmf.6/includes/MediaWiki.php(562): MediaWiki->main()
#11 /srv/mediawiki/php-1.40.0-wmf.6/index.php(50): MediaWiki->run()
#12 /srv/mediawiki/php-1.40.0-wmf.6/index.php(46): wfIndexMain()
#13 /srv/mediawiki/w/index.php(3): require(string)
#14 {main}
Impact
Notes

Started after promoting all wikis to 1.40.0-wmf.6. There were 9 occurrences all coming from jawiki. I am not sure why they hit /w/wiki.phtml isn't it a long deprecated entry point?

Some entries have $acunetix passed as parameters, maybe that is the penetration testing system https://www.acunetix.com/

Details

Request URL
https://ja.wikipedia.org/w/wiki.phtml?action%5B%5D=*&title=*
Related Changes in Gerrit:

Event Timeline

Some URLs have the string acunetix which is also referred to by T321133 which says:

Looks like some fuzzying urls (internet search for acunetix shows some related result)

Regardless the condition should be caught/handled ;)

Krinkle renamed this task from PHP Warning: preg_match() expects parameter 2 to be string, array given to PHP Warning: preg_match() expects parameter 2 to be string, array given (in Vector Hooks::shouldDisableMaxWidth).Oct 20 2022, 3:34 PM

Some URLs have the string acunetix which is also referred to by T321133 which says:

Looks like some fuzzying urls (internet search for acunetix shows some related result)

Regardless the condition should be caught/handled ;)

Yes, the backend should handle invalid values from the frontend better as a type error or fatal

When using WebRequest::getValues the array values are not discarded as done in WebRequest::getVal and mention there: "Array values are discarded for security reasons. Use {@see getArray} or {@see getIntArray}."
Requesting each value from WebRequest as needed is better as all and using it as array

Change 845038 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/skins/Vector@master] Use WebRequest directly in Hooks::shouldDisableMaxWidth

https://gerrit.wikimedia.org/r/845038

How can I test this one? Patch looks fine but have no idea what index.phtml is and how to replicate this on my local machine...

How can I test this one? Patch looks fine but have no idea what index.phtml is and how to replicate this on my local machine...

It fails also for the "normal" index.php, there is a rewrite rule from wiki.phtml to index.php in the config (not sure where)

Use

index.php?title=NotMainPage&action[]=history&useskin=vector-2022

with

$wgVectorMaxWidthOptions['exclude']['querystring']['action'] = '(history|edit)';

Can replicate that locally now, thanks!

Jdlrobson renamed this task from PHP Warning: preg_match() expects parameter 2 to be string, array given (in Vector Hooks::shouldDisableMaxWidth) to [subtask] PHP Warning: preg_match() expects parameter 2 to be string, array given (in Vector Hooks::shouldDisableMaxWidth).Oct 21 2022, 10:54 PM

Change 845038 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Use WebRequest directly in Hooks::shouldDisableMaxWidth

https://gerrit.wikimedia.org/r/845038

Thank you @Umherirrender , I really appreciate this kind of bugs to be addressed so quickly, the MediaWiki log errors stream thanks you as well!