r99484 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99483‎ | r99484 | r99485 >
Date:15:45, 11 October 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
list=allusers was throwing fatals when invalid user names occurred in the database. Address this scenario gracefully
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryAllUsers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllUsers.php
@@ -234,11 +234,13 @@
235235 ApiBase::dieDebug( __METHOD__,
236236 'MediaWiki configuration error: the database contains more user groups than known to User::getAllGroups() function' );
237237 }
 238+
 239+ $lastUserObj = User::newFromName( $lastUser );
238240
239241 // Add user's group info
240242 if ( $fld_groups ) {
241 - if ( !isset( $lastUserData['groups'] ) ) {
242 - $lastUserData['groups'] = ApiQueryUsers::getAutoGroups( User::newFromName( $lastUser ) );
 243+ if ( !isset( $lastUserData['groups'] ) && $lastUserObj ) {
 244+ $lastUserData['groups'] = ApiQueryUsers::getAutoGroups( $lastUserObj );
243245 }
244246
245247 if ( !is_null( $row->ug_group2 ) ) {
@@ -247,13 +249,13 @@
248250 $result->setIndexedTagName( $lastUserData['groups'], 'g' );
249251 }
250252
251 - if ( $fld_implicitgroups && !isset( $lastUserData['implicitgroups'] ) ) {
252 - $lastUserData['implicitgroups'] = ApiQueryUsers::getAutoGroups( User::newFromName( $lastUser ) );
 253+ if ( $fld_implicitgroups && !isset( $lastUserData['implicitgroups'] ) && $lastUserObj ) {
 254+ $lastUserData['implicitgroups'] = ApiQueryUsers::getAutoGroups( $lastUserObj );
253255 $result->setIndexedTagName( $lastUserData['implicitgroups'], 'g' );
254256 }
255257 if ( $fld_rights ) {
256 - if ( !isset( $lastUserData['rights'] ) ) {
257 - $lastUserData['rights'] = User::getGroupPermissions( User::newFromName( $lastUser )->getAutomaticGroups() );
 258+ if ( !isset( $lastUserData['rights'] ) && $lastUserObj ) {
 259+ $lastUserData['rights'] = User::getGroupPermissions( $lastUserObj->getAutomaticGroups() );
258260 }
259261 if ( !is_null( $row->ug_group2 ) ) {
260262 $lastUserData['rights'] = array_unique( array_merge( $lastUserData['rights'],

Follow-up revisions

RevisionCommit summaryAuthorDate
r994851.18wmf1: MFT r99484catrope15:46, 11 October 2011

Comments

#Comment by Nikerabbit (talk | contribs)   15:56, 11 October 2011

Really? $1 and :1337 don't cause any error in http://translatewiki.net/sandwiki/api.php?action=query&list=allusers

#Comment by Catrope (talk | contribs)   17:28, 11 October 2011
[05-Oct-2011 10:42:15] Fatal error: Call to a member function isAnon() on a non-object at /usr/local/apache/common-local/php-1.18/includes/api/ApiQueryUsers.php on line 262
Server: srv216
Method: GET
URL: [http://pl.wikipedia.org/w/api.php?action=query&list=allusers&auprop=groups%7Cblockinfo&aulimit=1&requestid=CENSORED&format=json http://pl.wikipedia.org/w/api.php?action=query&list=allusers&auprop=groups%7Cblockinfo&aulimit=1&requestid=CENSORED&format=json]
Backtrace:
#0 /usr/local/apache/common-local/php-1.18/includes/api/ApiQueryUsers.php(262): ApiQueryUsers::getAutoGroups()
#1 /usr/local/apache/common-local/php-1.18/includes/api/ApiQueryAllUsers.php(241): ApiQueryUsers::getAutoGroups(false)
#2 /usr/local/apache/common-local/php-1.18/includes/api/ApiQuery.php(270): ApiQueryAllUsers->execute()
#3 /usr/local/apache/common-local/php-1.18/includes/api/ApiMain.php(692): ApiQuery->execute()
#4 /usr/local/apache/common-local/php-1.18/includes/api/ApiMain.php(358): ApiMain->executeAction()
#5 /usr/local/apache/common-local/php-1.18/includes/api/ApiMain.php(342): ApiMain->executeActionWithErrorHandling()
#6 /usr/local/apache/common-local/php-1.18/api.php(115): ApiMain->execute()
#7 /usr/local/apache/common-local/live-1.5/api.php(3): require('/usr/local/apac...')
#8 {main}

Status & tagging log