Page MenuHomePhabricator

Error: Object of class stdClass could not be converted to string
Closed, ResolvedPublic

Description

The page:

returns an "Internal error" when visited:

[ed3fd25b-b894-4731-b5ed-7dcbbb9f3d7a] 2024-10-31 01:22:24: Fatal exception of type "Error"

Curiously, viewing the latest diff for that page works fine, even when using the preference setting to show the page content below the diff:

Also, while showing the latest revision using its permalink:

fails in the same way:

[f9970afc-c309-4f90-b976-9b542100f25e] 2024-10-31 01:40:37: Fatal exception of type "Error"

doing that with any previous revision of the page succeeds. For example:

works fine.

Finally, the corresponding discussion page works fine, too:

(Oh, and for the record, the text added in the diff linked above exists on several other pages on the wiki, and causes no problems on those pages.)

Error
labels.normalized_message
[{reqId}] {exception_url}   Error: Object of class stdClass could not be converted to string
FrameLocationCall
from/srv/mediawiki/php-1.44.0-wmf.1/includes/language/Message/Message.php(1355)
#0/srv/mediawiki/php-1.44.0-wmf.1/includes/language/Message/Message.php(1355)strtr(string, array)
#1/srv/mediawiki/php-1.44.0-wmf.1/includes/language/Message/Message.php(1043)MediaWiki\Message\Message->replaceParameters(string, string, string)
#2/srv/mediawiki/php-1.44.0-wmf.1/includes/language/Message/Message.php(1087)MediaWiki\Message\Message->format(string)
#3/srv/mediawiki/php-1.44.0-wmf.1/includes/OutputTransform/Stages/ParsoidLocalization.php(107)MediaWiki\Message\Message->parse()
#4/srv/mediawiki/php-1.44.0-wmf.1/includes/OutputTransform/Stages/ParsoidLocalization.php(86)MediaWiki\OutputTransform\Stages\ParsoidLocalization->localizeI18n(Wikimedia\Parsoid\NodeData\I18nInfo, Wikimedia\Bcp47Code\Bcp47CodeValue, Wikimedia\Parsoid\DOM\Document, bool)
#5/srv/mediawiki/php-1.44.0-wmf.1/includes/OutputTransform/Stages/ParsoidLocalization.php(41)MediaWiki\OutputTransform\Stages\ParsoidLocalization->localizeElement(Wikimedia\Parsoid\DOM\Element, Wikimedia\Bcp47Code\Bcp47CodeValue, Wikimedia\Parsoid\DOM\Document)
#6[internal function]MediaWiki\OutputTransform\Stages\ParsoidLocalization->MediaWiki\OutputTransform\Stages\{closure}(Wikimedia\Parsoid\DOM\Element, null)
#7/srv/mediawiki/php-1.44.0-wmf.1/vendor/wikimedia/parsoid/src/Utils/DOMTraverser.php(111)call_user_func(Closure, Wikimedia\Parsoid\DOM\Element, null)
#8/srv/mediawiki/php-1.44.0-wmf.1/vendor/wikimedia/parsoid/src/Utils/DOMTraverser.php(189)Wikimedia\Parsoid\Utils\DOMTraverser->callHandlers(Wikimedia\Parsoid\DOM\Element, null, null)
#9/srv/mediawiki/php-1.44.0-wmf.1/vendor/wikimedia/parsoid/src/Utils/DOMTraverser.php(204)Wikimedia\Parsoid\Utils\DOMTraverser->traverseInternal(bool, null, Wikimedia\Parsoid\DOM\Element, null)
#10/srv/mediawiki/php-1.44.0-wmf.1/vendor/wikimedia/parsoid/src/Utils/DOMTraverser.php(204)Wikimedia\Parsoid\Utils\DOMTraverser->traverseInternal(bool, null, Wikimedia\Parsoid\DOM\Element, null)
#11/srv/mediawiki/php-1.44.0-wmf.1/vendor/wikimedia/parsoid/src/Utils/DOMTraverser.php(204)Wikimedia\Parsoid\Utils\DOMTraverser->traverseInternal(bool, null, Wikimedia\Parsoid\DOM\Element, null)
#12/srv/mediawiki/php-1.44.0-wmf.1/vendor/wikimedia/parsoid/src/Utils/DOMTraverser.php(204)Wikimedia\Parsoid\Utils\DOMTraverser->traverseInternal(bool, null, Wikimedia\Parsoid\DOM\Element, null)
#13/srv/mediawiki/php-1.44.0-wmf.1/vendor/wikimedia/parsoid/src/Utils/DOMTraverser.php(204)Wikimedia\Parsoid\Utils\DOMTraverser->traverseInternal(bool, null, Wikimedia\Parsoid\DOM\Element, null)
#14/srv/mediawiki/php-1.44.0-wmf.1/vendor/wikimedia/parsoid/src/Utils/DOMTraverser.php(145)Wikimedia\Parsoid\Utils\DOMTraverser->traverseInternal(bool, null, Wikimedia\Parsoid\DOM\Document, null)
#15/srv/mediawiki/php-1.44.0-wmf.1/includes/OutputTransform/Stages/ParsoidLocalization.php(45)Wikimedia\Parsoid\Utils\DOMTraverser->traverse(null, Wikimedia\Parsoid\DOM\Document)
#16/srv/mediawiki/php-1.44.0-wmf.1/includes/OutputTransform/ContentDOMTransformStage.php(80)MediaWiki\OutputTransform\Stages\ParsoidLocalization->transformDOM(Wikimedia\Parsoid\DOM\Document, MediaWiki\Parser\ParserOutput, MediaWiki\Parser\ParserOptions, array)
#17/srv/mediawiki/php-1.44.0-wmf.1/includes/OutputTransform/ContentDOMTransformStage.php(37)MediaWiki\OutputTransform\ContentDOMTransformStage->parsoidTransform(MediaWiki\Parser\ParserOutput, MediaWiki\Parser\ParserOptions, array)
#18/srv/mediawiki/php-1.44.0-wmf.1/includes/OutputTransform/OutputTransformPipeline.php(80)MediaWiki\OutputTransform\ContentDOMTransformStage->transform(MediaWiki\Parser\ParserOutput, MediaWiki\Parser\ParserOptions, array)
#19/srv/mediawiki/php-1.44.0-wmf.1/includes/Output/OutputPage.php(2525)MediaWiki\OutputTransform\OutputTransformPipeline->run(MediaWiki\Parser\ParserOutput, MediaWiki\Parser\ParserOptions, array)
#20/srv/mediawiki/php-1.44.0-wmf.1/includes/Output/OutputPage.php(2571)MediaWiki\Output\OutputPage->getParserOutputText(MediaWiki\Parser\ParserOutput, array)
#21/srv/mediawiki/php-1.44.0-wmf.1/includes/page/Article.php(921)MediaWiki\Output\OutputPage->addParserOutput(MediaWiki\Parser\ParserOutput, array)
#22/srv/mediawiki/php-1.44.0-wmf.1/includes/page/Article.php(732)Article->doOutputFromParserCache(MediaWiki\Parser\ParserOutput, MediaWiki\Output\OutputPage, array)
#23/srv/mediawiki/php-1.44.0-wmf.1/includes/page/Article.php(547)Article->generateContentOutput(MediaWiki\User\User, MediaWiki\Parser\ParserOptions, int, MediaWiki\Output\OutputPage, array)
#24/srv/mediawiki/php-1.44.0-wmf.1/includes/actions/ViewAction.php(78)Article->view()
#25/srv/mediawiki/php-1.44.0-wmf.1/includes/actions/ActionEntryPoint.php(733)ViewAction->show()
#26/srv/mediawiki/php-1.44.0-wmf.1/includes/actions/ActionEntryPoint.php(510)MediaWiki\Actions\ActionEntryPoint->performAction(Article, MediaWiki\Title\Title)
#27/srv/mediawiki/php-1.44.0-wmf.1/includes/actions/ActionEntryPoint.php(146)MediaWiki\Actions\ActionEntryPoint->performRequest()
#28/srv/mediawiki/php-1.44.0-wmf.1/includes/MediaWikiEntryPoint.php(200)MediaWiki\Actions\ActionEntryPoint->execute()
#29/srv/mediawiki/php-1.44.0-wmf.1/index.php(58)MediaWiki\MediaWikiEntryPoint->run()
#30/srv/mediawiki/w/index.php(3)require(string)
#31{main}
Impact
Notes

Event Timeline

Ammarpad renamed this task from fix "internal error" caused by a page on bnwikivoyage to Error: Object of class stdClass could not be converted to string.Oct 31 2024, 5:20 AM
Ammarpad updated the task description. (Show Details)

Looks like someone is adding a stdclass as a parameter, which is then making replaceParameters crash because it expects an array of strings to strtr. The page uses Kartographer:

<mapframe text="Around the World in Eighty Days" width="900" height="280" latitude="33" longitude="8" align="right" zoom="2" show="listing">
{
    "type": "FeatureCollection",
...
}
</mapframe>

which triggers a strange-looking error in the legacy parser:

<div class="mw-kartographer-error">&lt;mapframe&gt;: JSON পার্স করা যায়নি: সিনট্যাক্স ত্রুটি</div>

There's this code in ParsoidTagHandler:

			foreach ( $errors[0]['params'] as $k => $p ) {
				if ( $p instanceof Message ) {
					$params[$k] = $p->toString( Message::FORMAT_PARSE );
				} else {
					$params[$k] = $p;
				}
			}

which was added in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Kartographer/+/1083876 to fix a CI issue. This crash is at a different place -- because the bad parameter seems to be an stdClass, we can actually serialize it just fine, it just blows up when we give it to Message to format. I'm actually not sure why the legacy parser doesn't die in the same way, but maybe serialization/deserialization isn't actually 100% faithful and we're looking at some object that serializes (to something that looks like a stdClass), but doesn't deserialize back to what it started as.

It's triggered by a JSON syntax error, which I fixed in https://bn.wikivoyage.org/w/index.php?title=%E0%A6%86%E0%A6%B6%E0%A6%BF_%E0%A6%A6%E0%A6%BF%E0%A6%A8%E0%A7%87_%E0%A6%AC%E0%A6%BF%E0%A6%B6%E0%A7%8D%E0%A6%AC%E0%A6%AD%E0%A7%8D%E0%A6%B0%E0%A6%AE%E0%A6%A3&diff=57136&oldid=55957

On my local debug machine, however, Parsoid handles this just fine, displaying "<mapframe>: Couldn't parse JSON: Syntax error" just like the legacy parser does.

I suspect this was actually bad parser cache contents generated by 1.43-<whatever> being deserialized by 1.44 which then crashed on it. Purging the cache seems to make this page work again, even for the old revisions with the bad JSON.

cscott claimed this task.