* (bug 10902) Unable to fetch user contributions from IP addresses
authorRob Church <robchurch@users.mediawiki.org>
Mon, 13 Aug 2007 18:15:35 +0000 (18:15 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 13 Aug 2007 18:15:35 +0000 (18:15 +0000)
* `list=usercontribs` no longer requires that the user exist

RELEASE-NOTES
includes/api/ApiQueryUserContributions.php

index ddae990..700284c 100644 (file)
@@ -430,6 +430,8 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API
 * Added rvprop=size to prop=revisions (The size will not be shown if it is NULL in the database)
 * list=allpages now allows to filter by article min/max size and protection status
 * Added site statistics (siprop=statistics for meta=siteinfo)
+* (bug 10902) Unable to fetch user contributions from IP addresses
+* `list=usercontribs` no longer requires that the user exist
 
 == Maintenance script changes since 1.10 ==
 
index edcd614..2e18647 100644 (file)
@@ -93,27 +93,23 @@ class ApiQueryContributions extends ApiQueryBase {
        }
 
        /**
-        * Convert 'user' parameter into a proper user login name.
-        * This method also validates that this user actually exists in the database.  
+        * Validate the 'user' parameter and set the value to compare
+        * against `revision`.`rev_user_text`
         */
        private function getUserTitle() {
-
                $user = $this->params['user'];
-               if (is_null($user))
-                       $this->dieUsage("User parameter may not be empty", 'param_user');
-
-               $userTitle = Title::makeTitleSafe( NS_USER, $user );
-               if ( is_null( $userTitle ) )
-                       $this->dieUsage("User name $user is not valid", 'param_user');
-
-               $userid = $this->getDB()->selectField('user', 'user_id', array (
-                       'user_name' => $userTitle->getText()
-               ));
-               
-               if (!$userid)
-                       $this->dieUsage("User name $user not found", 'param_user');
-                       
-               $this->userTitle = $userTitle;
+               if( $user ) {
+                       $name = User::isIP( $user )
+                               ? $user
+                               : User::getCanonicalName( $user, 'valid' );
+                       if( $name === false ) {
+                               $this->dieUsage( "User name {$user} is not valid", 'param_user' );
+                       } else {
+                               $this->userTitle = $name;
+                       }
+               } else {
+                       $this->dieUsage( 'User parameter may not be empty', 'param_user' );
+               }
        }
        
        /**
@@ -129,7 +125,7 @@ class ApiQueryContributions extends ApiQueryBase {
                $this->addWhereFld('rev_deleted', 0);
                
                // We only want pages by the specified user.
-               $this->addWhereFld('rev_user_text', $this->userTitle->getText());
+               $this->addWhereFld( 'rev_user_text', $this->userTitle );
 
                // ... and in the specified timeframe.
                $this->addWhereRange('rev_timestamp',