Page MenuHomePhabricator

"Invalid argument supplied for foreach" in User::saveOptions() during automatic account creation
Closed, ResolvedPublic


Since 1.21wmf2 we are logging "invalid argument supplied for foreach" errors in User::saveOptions(). Debugging on the live site indicates that this is caused by interaction between a recent change to CentralAuth (I92f57fc2) a long-standing bug in User::clearInstanceCache(), and AbuseFilter #18 on

User::clearInstanceCache() clears $this->mOptions but does not set $this->mOptionsLoaded to false, as would be expected for a cache clear. It is called by addToDatabase(). This is not normally a problem for CentralAuth:: attemptAddUser() since it calls User::loadDefaults() before it calls addToDatabase(), and loadDefaults() does set $this->mOptionsLoaded to false.

I92f57fc2 rearranged the calling sequence so that the AbortAutoAccount hook is called in between the loadDefaults() call and the addToDatabase() call. When an AbortAutoAccount hook function then loads the user options for some reason, the invalid state is created and User::addToDatabase() generates the warning.

AF #18 on loads the user options when AbuseFilter::executeFilterActions() calls $wgOut->parseInline(), which constructs a ParserOptions object.

Version: 1.21.x
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:01 AM
bzimport set Reference to bz41198.
bzimport added a subscriber: Unknown Object (MLST).

Dup of bug 41175? However this one has a perfect analysis that I'd love to see copied to 41175 in case I'm correct. :)

  • Bug 41175 has been marked as a duplicate of this bug. ***
Restricted Application added a subscriber: StudiesWorld. · View Herald TranscriptJan 28 2016, 6:12 PM