From 5a5642fa3e845b0864f72e3e47b9ac54baf6be66 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 13 Aug 2007 18:15:35 +0000 Subject: [PATCH] * (bug 10902) Unable to fetch user contributions from IP addresses * `list=usercontribs` no longer requires that the user exist --- RELEASE-NOTES | 2 ++ includes/api/ApiQueryUserContributions.php | 34 ++++++++++------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ddae990fb1..700284c216 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index edcd614ec9..2e18647f36 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -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', -- 2.20.1