Page MenuHomePhabricator

PHP warning in BagOStuff::proxyCall for DB-backed stash
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce:

  • Setup your main object stash to be DB-backed (this is the default setting of MediaWiki) by adding $wgMainStash = 'db-replicated'; at the end of LocalSettings.php.
  • Try using the setMulti() method on the main stash. An example for this in MW's REPL is shown below.
>>> $s = \MediaWiki\MediaWikiServices::getInstance()->getMainObjectStash()
=> ReplicatedBagOStuff {#2825}
>>> $s->setMulti(['key' => 'val'])
<warning>PHP Warning:  Invalid argument supplied for foreach() in /vagrant/mediawiki/includes/libs/objectcache/BagOStuff.php on line 755</warning>
=> []

Any valid call to the setMulti method will trigger a PHP warning that will also show up in logs and on the web pages (ugh).

The culprit can be found in the ReplicatedBagOStuff::setMulti method (source for 1.36) which calls the proxyCall method with RES_KEYMAP as its third argument, instead of RES_NONKEY (because setMulti returns a bool, not an array).

Software version:
I have verified this on 1.36 and current master. It's possible older versions are affected as well.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 719269 had a related patch set uploaded (by Ostrzyciel; author: Ostrzyciel):

[mediawiki/core@master] Fix PHP warning for ReplicatedBagOStuff::setMulti

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

Change 719174 had a related patch set uploaded (by Ostrzyciel; author: Ostrzyciel):

[mediawiki/core@REL1_36] Fix PHP warning for ReplicatedBagOStuff::setMulti

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

I've submitted patches to master and REL1_36 to fix this. REL1_35 is unaffected, as said method didn't use proxyCall back then.

Change 719269 merged by jenkins-bot:

[mediawiki/core@master] objectcache: Fix PHP warning for ReplicatedBagOStuff::setMulti

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

Change 719174 merged by jenkins-bot:

[mediawiki/core@REL1_36] objectcache: Fix PHP warning for ReplicatedBagOStuff::setMulti

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

Krinkle claimed this task.