Page MenuHomePhabricator

Uncaught ArgumentCountError: Too few arguments to function OOUI\Tag::appendContent(), 0 passed
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

MediaWiki version: 1.36.0-wmf.3

message
PHP Fatal Error: Uncaught ArgumentCountError: Too few arguments to function OOUI\Tag::appendContent(), 0 passed in /srv/mediawiki/php-1.36.0-wmf.3/extensions/WikibaseMediaInfo/src/View/MediaInfoEntityTermsView.php on line 91 and exactly 1 expected in /srv/mediawiki/php-1.36.0-wmf.3/vendor/oojs/oojs-ui/php/Tag.php:216
Stack trace:
#0 /srv/mediawiki/php-1.36.0-wmf.3/extensions/WikibaseMediaInfo/src/View/MediaInfoEntityTermsView.php(91): OOUI\Tag->appendContent()
#1 /srv/mediawiki/php-1.36.0-wmf.3/extensions/WikibaseMediaInfo/src/View/MediaInfoView.php(86): Wikibase\MediaInfo\View\MediaInfoEntityTermsView->getHtml(Object(Wikibase\MediaInfo\DataModel\MediaInfo))
#2 /srv/mediawiki/php-1.36.0-wmf.3/extensions/WikibaseMediaInfo/src/View/MediaInfoView.php(79): Wikibase\MediaInfo\View\MediaInfoView->getCaptionsHtml(Object(Wikibase\MediaInfo\DataModel\MediaInfo))
#3 /srv/mediawiki/php-1.36.0-wmf.3/extensions/WikibaseMediaInfo/src/WikibaseMediaInfoHooks.php(528): Wikibase\MediaInfo\View\MediaInfoView->getContent(Object(Wikibase\MediaInf

Impact / Notes

28+ of these and slowly ticking up within the first 15 minutes or so of rolling 1.36.0-wmf.3 to group1.

Details

Request ID
294ae929-5af3-4846-a3e2-36a34f0e33e5
Request URL
https://commons.wikimedia.org/wiki/File:Cuba_physical_map_(no_legend).svg?uselang=%E2%A7%BCLang%E2%A7%BD
Stack Trace
exception.trace
#0 [internal function]: MWExceptionHandler::handleFatalError()
#1 {main}

Event Timeline

brennen created this task.Aug 5 2020, 7:44 PM
Restricted Application added a project: Wikidata. · View Herald TranscriptAug 5 2020, 7:44 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
brennen triaged this task as Unbreak Now! priority.Aug 5 2020, 7:44 PM
Catrope added a subscriber: Catrope.Aug 5 2020, 8:26 PM

The relevant code is

		$layout->appendContent(
			...$this->getCaptionsContent(
				$entity->getLabels(),
				$this->getLanguagesOrderedByFallbackChain( $entity )
			)
		);

I think the simplest fix would be to simply remove the spread operator (...), since appendContent() can also be called with an array as the only parameter.

brennen moved this task from Backlog to Logs/Train on the User-brennen board.Aug 6 2020, 12:05 AM

Change 618643 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/extensions/WikibaseMediaInfo@master] Fix array unpacking as argument list

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

Ammarpad claimed this task.Aug 6 2020, 2:56 AM

Change 618643 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Fix array unpacking as argument list

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

The problematic ... was added in patch https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikibaseMediaInfo/+/538388 (T224772) by @Umherirrender 10 months ago. I think I understand why: I believe Phan gets confused by how the called \OOUI\Tag::appendContent() method is documented. The method accepts any number of string, \OOUI\Tag, or \OOUI\HtmlSnippet in whatever combination and order, either as an array or as a list of parameters. So the documentation would need to say something like string|Tag|HtmlSnippet|(string|Tag|HtmlSnippet)[], but talks about a generic array instead.

Note that while adding the ... slightly changed the semantics (while an array can be empty, a list of parameters can not), this was not a mistake! According to the documentation of getLanguagesOrderedByFallbackChain() it can never return an empty array, so getCaptionsContent() can never be an empty array as well. I believe there is another bug that makes these methods return empty arrays. I created T259779: LanguageFallbackChainFactory returns empty fallback chain when it shouldn't to keep track of this.

Change 618582 had a related patch set uploaded (by Brennen Bearnes; owner: Ammarpad):
[mediawiki/extensions/WikibaseMediaInfo@wmf/1.36.0-wmf.3] Fix array unpacking as argument list

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

Change 618582 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@wmf/1.36.0-wmf.3] Fix array unpacking as argument list

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

Mentioned in SAL (#wikimedia-operations) [2020-08-06T17:36:14Z] <brennen@deploy1001> Synchronized php-1.36.0-wmf.3/extensions/WikibaseMediaInfo/src/View/MediaInfoEntityTermsView.php: Backport: [[gerrit:618582|Fix array unpacking as argument list]] (T259745) (duration: 01m 07s)

Ammarpad closed this task as Resolved.Aug 7 2020, 12:28 AM
Krinkle moved this task from Inbox to Confirmed Problem on the OOjs board.Aug 14 2020, 1:47 PM