[Mediawiki-l] Solving the GROUP BY problem
tstarling at wikimedia.org
Sat Apr 30 01:00:19 UTC 2011
On 29/04/11 23:52, Greg Sabino Mullane wrote:
> Tim Starling <tstarling at wikimedia.org> wrote:
>> You could add a static function to User which provides the field name
>> array. If it were used in User::loadFromDatabase(), then it would be
>> immune to bit rot.
> Dug into this a little bit, but is it promised that loadFromDatabase will
> be called early enough? Such as the case of a non-logged in user getting
> a list of contributions for an article?
I'm not sure what you mean. In your sample code, UserArray was used,
which will create User objects with User::newFromRow().
User::loadFromDatabase() won't be used in that case, it's only used
for cases where the user ID is known but the rest of the data isn't.
The reason it's important to use the new method, say
User::getFieldNames(), in User::loadFromDatabase() is so that when new
fields are added, they have to be added to User::getFieldNames() or
else they won't be accessible in User::loadFromRow() in the most
common cases. The developer will have to add the field to the field
list, or else it won't work at all.
We want to avoid introducing a field list which is used only in
rarely-tested code, because such field lists are likely to be poorly
-- Tim Starling
More information about the MediaWiki-l