Page MenuHomePhabricator

PHP Warning: json_decode() expects parameter 1 to be string, array given
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Warning: json_decode() expects parameter 1 to be string, array given
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.20/extensions/GrowthExperiments/includes/VisualEditorHooks.php(117)
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.37.0-wmf.20/extensions/GrowthExperiments/includes/VisualEditorHooks.php(117): json_decode(array, boolean)
#2 /srv/mediawiki/php-1.37.0-wmf.20/includes/HookContainer/HookContainer.php(160): GrowthExperiments\VisualEditorHooks->onVisualEditorApiVisualEditorEditPostSave(MediaWiki\Page\PageIdentityValue, User, string, array, array, array, array)
#3 /srv/mediawiki/php-1.37.0-wmf.20/extensions/VisualEditor/includes/VisualEditorHookRunner.php(72): MediaWiki\HookContainer\HookContainer->run(string, array, array)
#4 /srv/mediawiki/php-1.37.0-wmf.20/extensions/VisualEditor/includes/ApiVisualEditorEdit.php(517): MediaWiki\Extension\VisualEditor\VisualEditorHookRunner->onVisualEditorApiVisualEditorEditPostSave(MediaWiki\Page\PageIdentityValue, User, string, array, array, array, array)
#5 /srv/mediawiki/php-1.37.0-wmf.20/includes/api/ApiMain.php(1844): ApiVisualEditorEdit->execute()
#6 /srv/mediawiki/php-1.37.0-wmf.20/includes/api/ApiMain.php(823): ApiMain->executeAction()
#7 /srv/mediawiki/php-1.37.0-wmf.20/includes/api/ApiMain.php(794): ApiMain->executeActionWithErrorHandling()
#8 /srv/mediawiki/php-1.37.0-wmf.20/api.php(90): ApiMain->execute()
#9 /srv/mediawiki/php-1.37.0-wmf.20/api.php(45): wfApiMain()
#10 /srv/mediawiki/w/api.php(3): require(string)
#11 {main}
Impact

The post save code used by GrowthExperiments fails. Not sure yet if this also causes the edit to fail entirely.

Notes

There are some related messages in Logstash:

  • PHP Notice: Undefined index: acceptedTargets
  • PHP Notice: Undefined index: rejectedTargets
  • PHP Notice: Undefined index: skippedTargets

Event Timeline

kostajh triaged this task as High priority.

Change 714698 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/GrowthExperiments@master] VisualEditorHooks: Access first item from pluginData

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

It's client-provided data, in theory strait from JSON.stringify. All four instances of the error are on testwiki. Could it be someone manually experimenting with the response data?

Change 714705 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/VisualEditor@master] ApiVisualEditorEdit: data-{plugin} is not multi

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

Change 714698 abandoned by Kosta Harlan:

[mediawiki/extensions/GrowthExperiments@master] VisualEditorHooks: Access first item from pluginData

Reason:

Ife8350d1cea79fc1dd6f3cb040a7801b9fe6db91

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

It's client-provided data, in theory strait from JSON.stringify. All four instances of the error are on testwiki. Could it be someone manually experimenting with the response data?

No, it's broken in the normal interaction scenario with link recommendations. It's caused by switching to using $params instead of accessing the request object directly, which was done in the patch for the new PreSave hook that is in wmf.20.

Change 714705 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] ApiVisualEditorEdit: data-{plugin} is not multi

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

Change 714670 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/VisualEditor@wmf/1.37.0-wmf.20] ApiVisualEditorEdit: data-{plugin} is not multi

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

Change 714670 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@wmf/1.37.0-wmf.20] ApiVisualEditorEdit: data-{plugin} is not multi

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

Mentioned in SAL (#wikimedia-operations) [2021-08-25T11:32:46Z] <kharlan@deploy1002> Synchronized php-1.37.0-wmf.20/extensions/VisualEditor/includes/ApiVisualEditorEdit.php: Backport: [[gerrit:714670|ApiVisualEditorEdit: data-{plugin} is not multi (T289652)]] (duration: 01m 06s)

Etonkovidova subscribed.

Checked in wmf.20 - the last timestamp was Aug 25, 2021 @ 11:27:35.688 ( see the link: PHP Warning: json_decode() expects parameter 1 to be string, array given) before the patch https://gerrit.wikimedia.org/r/714670 was deployed.