Page MenuHomePhabricator

TypeError: Argument 1 passed to MediaWiki\Parser\Sanitizer::encodeAttribute() must be of the type string, null given, called in /srv/mediawiki/php-1.42.0-wmf.15/includes/xml/Xml.php on line 81
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
labels.normalized_message
[{reqId}] {exception_url}   TypeError: Argument 1 passed to MediaWiki\Parser\Sanitizer::encodeAttribute() must be of the type string, null given, called in /srv/mediawiki/php-1.42.0-wmf.15/includes/xml/Xml.php on line 81
error.stack_trace
from /srv/mediawiki/php-1.42.0-wmf.15/includes/parser/Sanitizer.php(845)
#0 /srv/mediawiki/php-1.42.0-wmf.15/includes/xml/Xml.php(81): MediaWiki\Parser\Sanitizer::encodeAttribute(NULL)
#1 /srv/mediawiki/php-1.42.0-wmf.15/includes/xml/Xml.php(55): Xml::expandAttributes(array)
#2 /srv/mediawiki/php-1.42.0-wmf.15/includes/xml/Xml.php(299): Xml::element(string, array)
#3 /srv/mediawiki/php-1.42.0-wmf.15/includes/xml/Xml.php(417): Xml::input(string, integer, NULL, array)
#4 /srv/mediawiki/php-1.42.0-wmf.15/includes/xml/Xml.php(396): Xml::inputLabelSep(string, string, string, integer, NULL, array)
#5 /srv/mediawiki/php-1.42.0-wmf.15/extensions/LiquidThreads/includes/LqtView.php(977): Xml::inputLabel(string, string, string, integer, NULL, array)
#6 /srv/mediawiki/php-1.42.0-wmf.15/extensions/LiquidThreads/includes/LqtView.php(586): LqtView->getSubjectEditor(string, NULL)
#7 /srv/mediawiki/php-1.42.0-wmf.15/extensions/LiquidThreads/includes/LqtView.php(419): LqtView->showNewThreadForm(Article)
#8 /srv/mediawiki/php-1.42.0-wmf.15/extensions/LiquidThreads/includes/LqtView.php(489): LqtView->doInlineEditForm()
#9 /srv/mediawiki/php-1.42.0-wmf.15/extensions/LiquidThreads/includes/Api/ApiThreadAction.php(902): LqtView::getInlineEditForm(Article, string, NULL, MediaWiki\User\User)
#10 [internal function]: MediaWiki\Extension\LiquidThreads\Api\ApiThreadAction->actionInlineEditForm(array, array)
#11 /srv/mediawiki/php-1.42.0-wmf.15/extensions/LiquidThreads/includes/Api/ApiThreadAction.php(75): call_user_func_array(array, array)
#12 /srv/mediawiki/php-1.42.0-wmf.15/includes/api/ApiMain.php(1942): MediaWiki\Extension\LiquidThreads\Api\ApiThreadAction->execute()
#13 /srv/mediawiki/php-1.42.0-wmf.15/includes/api/ApiMain.php(917): ApiMain->executeAction()
#14 /srv/mediawiki/php-1.42.0-wmf.15/includes/api/ApiMain.php(888): ApiMain->executeActionWithErrorHandling()
#15 /srv/mediawiki/php-1.42.0-wmf.15/api.php(95): ApiMain->execute()
#16 /srv/mediawiki/php-1.42.0-wmf.15/api.php(48): wfApiMain()
#17 /srv/mediawiki/w/api.php(3): require(string)
#18 {main}
Impact
Notes

That is similar to T355751 and the root cause is MediaWiki\Parser\Sanitizer::escapeHtmlAllowEntities() had types added by e263306d40bf968fd95bd3856c71a7c33ca2d44b:

-       public static function escapeHtmlAllowEntities( $html ) {
+       public static function escapeHtmlAllowEntities( string $html ): string {

The change is https://gerrit.wikimedia.org/r/c/mediawiki/core/+/984165 which got merged on January 19th and is first deployed as part of 1.42.0-wmf.15.

MediaWiki-extensions-LiquidThreads needs to be adjusted to not pass a null, my guess that is from

#6 /srv/mediawiki/php-1.42.0-wmf.15/extensions/LiquidThreads/includes/LqtView.php(586): LqtView->getSubjectEditor(string, NULL)

Details

MediaWiki Version
1.42.0-wmf.15
Request URL
https://en.wiktionary.org/w/api.php

Event Timeline

Funnily Phan did detect the issue with Null?:

585         // @phan-suppress-next-line PhanTypeMismatchArgumentNullable
586         $e->editFormTextBeforeContent .= $this->getSubjectEditor( '', $subject );

The subject comes from a POST which is retrieved using WebRequest->getVal() which returns a null. So we gotta coalesced that to false which is used in getSubjectEditor().

Change 992939 had a related patch set uploaded (by Hashar; author: Hashar):

[mediawiki/extensions/LiquidThreads@master] Fix handling of empty subject

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

Change 992939 merged by jenkins-bot:

[mediawiki/extensions/LiquidThreads@master] Fix handling of empty subject

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

I think this is fixed, though there’s a similar error in ImageMap (T357668).