r97795 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97794‎ | r97795 | r97796 >
Date:06:17, 22 September 2011
Author:tstarling
Status:ok
Tags:
Comment:
Fixed User::getGroups(), apparently broken since r33333. User::load() doesn't load groups anymore, so calling $this->getGroups() was the same as just accessing $this->mGroups. Usually it doesn't matter, since most factory functions are funnelled into loadFromId() which calls loadGroups() or loads the groups from the cache, but loadFromRow() was potentially broken.

It's necessary for User::loadFromRow() to set $this->mGroups to null, same as the calling code in User::loadFromDatabase(), so that they will be loaded dynamically when User::newFromRow() is called.

No bugs found that are caused by this but it couldn't hurt to have working accessors. Tested from eval.php.
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1053,6 +1053,8 @@
10541054 public function loadFromRow( $row ) {
10551055 $all = true;
10561056
 1057+ $this->mGroups = null; // deferred
 1058+
10571059 if ( isset( $row->user_name ) ) {
10581060 $this->mName = $row->user_name;
10591061 $this->mFrom = 'name';
@@ -2312,6 +2314,7 @@
23132315 */
23142316 public function getGroups() {
23152317 $this->load();
 2318+ $this->loadGroups();
23162319 return $this->mGroups;
23172320 }
23182321

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r33333In User:...tstarling09:04, 15 April 2008

Status & tagging log