From: Brion Vibber Date: Thu, 10 Apr 2008 17:18:27 +0000 (+0000) Subject: Revert 33072 for now -- changes to ucuserprefix use X-Git-Tag: 1.31.0-rc.0~48458 X-Git-Url: https://git.cyclocoop.org/admin/%7B%7Blocalurl:Special:UserLogin%7D%7D?a=commitdiff_plain;h=7b6fd38bc2d06d1853b9a3f4b86ed463b9d6489f;p=lhc%2Fweb%2Fwiklou.git Revert 33072 for now -- changes to ucuserprefix use Using the user_timestamp index means you can't do an indexed search on the name prefix... Basically the same as scanning raw on rev_timestamp, but with logged-in edits skipped so you don't scan *quite* as huge an amount of the table. Since there's no index for the username prefix, the more specific the prefix, the *more* rows you'll have to scan through to fill out the result set, so the worse the performance will get. --- diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index f0097b1cd0..672c16cbf3 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -62,8 +62,6 @@ class ApiQueryContributions extends ApiQueryBase { if(isset($this->params['userprefix'])) { - if(!preg_match('/^\d{1,3}\.\d{1,3}\./', $this->params['userprefix'])) - $this->dieUsage("ucuserprefix must contain at least two octets terminated by a period", 'baduserprefix'); $this->prefixMode = true; $this->userprefix = $this->params['userprefix']; } @@ -139,13 +137,13 @@ class ApiQueryContributions extends ApiQueryBase { $this->addWhereFld('rev_deleted', 0); // We only want pages by the specified users. if($this->prefixMode) - { - $this->addWhere(array('rev_user' => 0)); $this->addWhere("rev_user_text LIKE '" . $this->getDb()->escapeLike($this->userprefix) . "%'"); - } else $this->addWhereFld( 'rev_user_text', $this->usernames ); // ... and in the specified timeframe. + // Ensure the same sort order for rev_user_text and rev_timestamp + // so our query is indexed + $this->addWhereRange('rev_user_text', $this->params['dir'], null, null); $this->addWhereRange('rev_timestamp', $this->params['dir'], $this->params['start'], $this->params['end'] ); $this->addWhereFld('page_namespace', $this->params['namespace']); @@ -270,10 +268,7 @@ class ApiQueryContributions extends ApiQueryBase { 'start' => 'The start timestamp to return from.', 'end' => 'The end timestamp to return to.', 'user' => 'The user to retrieve contributions for.', - 'userprefix' => array( - 'Retrieve contibutions for all IP addresses that begin with this value.', - 'Overrides ucuser. Must contain at least two octets terminated by a period' - ), + 'userprefix' => 'Retrieve contibutions for all users whose names begin with this value. Overrides ucuser.', 'dir' => 'The direction to search (older or newer).', 'namespace' => 'Only list contributions in these namespaces', 'prop' => 'Include additional pieces of information',