Page MenuHomePhabricator

Fatal error: Call to undefined method OOUI\Element::serializeForApiResult() in /srv/mediawiki/php-1.26wmf21/vendor/oojs/oojs-ui/php/Element.php on line 117
Closed, ResolvedPublic

Description

24 fatal errors in fatalmonitor for 1.26wmf21

Fatal error: Call to undefined method OOUI\Element::serializeForApiResult() in /srv/mediawiki/php-1.26wmf21/vendor/oojs/oojs-ui/php/Element.php on line 117

To replicate:
Add page WikidataPageBanner

{{PAGEBANNER:Alberta (Canada) banner Herbert lake shore.png|icon-unesco=Foo|icon-bar=Dam}}
test testzz
zz

Visit
http://localhost:8888/w/api.php?action=parse&format=json&page=WikidataPageBanner&prop=properties

Event Timeline

mmodell raised the priority of this task from to Needs Triage.
mmodell updated the task description. (Show Details)
mmodell subscribed.
Jdforrester-WMF set Security to None.
Jdforrester-WMF subscribed.

Did we work out who's mis-calling this? ISTR suspicion was pointed at the new WikivoyagePageBanner?

@Jdforrester-WMF: That sounds like a likely culprit, but I'm not entirely sure.

Krenair subscribed.

There was some discussion about this in #wikimedia-editing on 31st August.

Sep 01 00:24:52 <Krenair>	I feel like we've tried to investigate similar issues where code was trying to output OOUI objects in the API before
Sep 01 00:26:21 <Krenair>	I remember that security issue in the unblock API where the XML formatter was running toString on objects, but with JSON we just dumped the raw user object - emails, password hashes and all. No idea if it would be related, but I would certainly avoid sending objects straight into the API results
Sep 01 00:27:32 <Krenair>	Oh, there we are: https://phabricator.wikimedia.org/P1856
Sep 01 00:28:22 <Krenair>	no task, just my paste from a couple of weeks ago. I wonder what Wikidata-Page-Banner had to do with it

The traceback pointed to OOUI\\IconWidget, which AFAIK only WikidataPageBanner is using near anything that is parsing pages.

Unfortunately since it's fataling the request parameters don't make it into api.log. But I only see two things using OOUI\IconWidget: OOUI\FieldLayout, which would probably have run into the problem first before getting to the contained IconWidget, and WikidataPageBanner. Digging through that code, it looks like it's passing the IconWidget into OutputPage::setProperty, which leads me to this as a reproduction.

A large part of the problem is the interaction between __call and is_callable: ApiResult uses is_callable to try to determine whether the method exists before calling it, but is_callable apparently always returns true if __call exists. It doesn't use an interface, although one exists, so that extensions can maintain backwards compatibility.

The easiest solution may be to implement serializeForApiResult() on OOUI\Element or OOUI\Tag, probably to just return (string)$this. In this particular case, in the absence of the issue with __call and is_callable that's what ApiResult would do anyway since __toString() exists on the object.

Is this issue likely to be with how WikidataPageBanner is using OOUI or is it an issue in OOUI itself. Can anyone advise?

WikidataPageBanner is dumping the OOUI object into ParserOutput's properties, where they'll get saved to the pageprops table and be output by the API. If you don't actually need them saved to the pageprops table or output by the API, you should probably be using setExtensionData() instead.

ori raised the priority of this task from Medium to High.Sep 8 2015, 9:47 PM
ori added subscribers: greg, ori.

This is *still* causing fatals in production. Can somebody fix this, please? @greg, could you please look after this? Anomie's suggestion from T111304#1606372 is sound.

@Jdlrobson / @Lydia_Pintscher: can one of you confirm someone is on point to fix this in WikidataPageBanner?

Jdlrobson updated the task description. (Show Details)

I'll take a look.

Change 236977 had a related patch set uploaded (by Jdlrobson):
Delay rendering of OOUI icons until banner rendering

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

Someone will need to +2 it though.. I'm not sure who has +2/familiarity with this extension other than me and @Bene ...

The patch breaks unit tests. The tests need to be fixed along with this change.

Pretty stack trace with new Monlog configuration:

2015-09-09 19:22:24 mw1207 enwikivoyage fatal ERROR: [4b981d65] PHP Fatal Error: Call to undefined method OOUI\Element::serializeForApiResult() {"exception_id":"4b981d65"}
[Exception ErrorException] (/srv/mediawiki/php-1.26wmf22/vendor/oojs/oojs-ui/php/Element.php:117) PHP Fatal Error: Call to undefined method OOUI\Element::serializeForApiResult()
  #0 /srv/mediawiki/php-1.26wmf22/vendor/oojs/oojs-ui/php/Element.php(117): trigger_error(string, integer)
  #1 /srv/mediawiki/php-1.26wmf22/includes/api/ApiResult.php(340): OOUI\Element->__call(string, array)
  #2 /srv/mediawiki/php-1.26wmf22/includes/api/ApiResult.php(368): ApiResult::validateValue(OOUI\IconWidget)
  #3 /srv/mediawiki/php-1.26wmf22/includes/api/ApiResult.php(368): ApiResult::validateValue(array)
  #4 /srv/mediawiki/php-1.26wmf22/includes/api/ApiResult.php(368): ApiResult::validateValue(array)
  #5 /srv/mediawiki/php-1.26wmf22/includes/api/ApiResult.php(368): ApiResult::validateValue(array)
  #6 /srv/mediawiki/php-1.26wmf22/includes/api/ApiResult.php(368): ApiResult::validateValue(array)
  #7 /srv/mediawiki/php-1.26wmf22/includes/api/ApiResult.php(292): ApiResult::validateValue(array)
  #8 /srv/mediawiki/php-1.26wmf22/includes/api/ApiResult.php(417): ApiResult::setValue(array, string, array, integer)
  #9 /srv/mediawiki/php-1.26wmf22/includes/api/ApiExpandTemplates.php(170): ApiResult->addValue(NULL, string, array)
  #10 /srv/mediawiki/php-1.26wmf22/includes/api/ApiMain.php(1093): ApiExpandTemplates->execute()
  #11 /srv/mediawiki/php-1.26wmf22/includes/api/ApiMain.php(432): ApiMain->executeAction()
  #12 /srv/mediawiki/php-1.26wmf22/includes/api/ApiMain.php(405): ApiMain->executeActionWithErrorHandling()
  #13 /srv/mediawiki/php-1.26wmf22/api.php(88): ApiMain->execute()
  #14 /srv/mediawiki/w/api.php(3): include(string)
  #15 {main}

Change 237302 had a related patch set uploaded (by BryanDavis):
Delay rendering of OOUI icons until banner rendering

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

Change 236977 merged by jenkins-bot:
Delay rendering of OOUI icons until banner rendering

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

JanZerebecki moved this task from monitoring to hold on the Wikidata board.

Change 237302 merged by jenkins-bot:
Delay rendering of OOUI icons until banner rendering

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

Let me know if you are still seeing fatals!