| Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php |
| — | — | @@ -111,8 +111,6 @@ |
| 112 | 112 | |
| 113 | 113 | $this->addOption('LIMIT', $params['limit'] + 1); |
| 114 | 114 | $this->addWhereRange('ar_timestamp', $params['dir'], $params['start'], $params['end']); |
| 115 | | - if(isset($params['namespace'])) |
| 116 | | - $this->addWhereFld('ar_namespace', $params['namespace']); |
| 117 | 115 | $res = $this->select(__METHOD__); |
| 118 | 116 | $pages = array(); |
| 119 | 117 | $count = 0; |
| — | — | @@ -183,10 +181,6 @@ |
| 184 | 182 | ), |
| 185 | 183 | ApiBase :: PARAM_DFLT => 'older' |
| 186 | 184 | ), |
| 187 | | - 'namespace' => array( |
| 188 | | - ApiBase :: PARAM_ISMULTI => true, |
| 189 | | - ApiBase :: PARAM_TYPE => 'namespace' |
| 190 | | - ), |
| 191 | 185 | 'limit' => array( |
| 192 | 186 | ApiBase :: PARAM_DFLT => 10, |
| 193 | 187 | ApiBase :: PARAM_TYPE => 'limit', |
| — | — | @@ -215,7 +209,6 @@ |
| 216 | 210 | 'start' => 'The timestamp to start enumerating from', |
| 217 | 211 | 'end' => 'The timestamp to stop enumerating at', |
| 218 | 212 | 'dir' => 'The direction in which to enumerate', |
| 219 | | - 'namespace' => 'The namespaces to search in', |
| 220 | 213 | 'limit' => 'The maximum amount of revisions to list', |
| 221 | 214 | 'prop' => 'Which properties to get' |
| 222 | 215 | ); |
| — | — | @@ -227,8 +220,8 @@ |
| 228 | 221 | |
| 229 | 222 | protected function getExamples() { |
| 230 | 223 | return array ( |
| 231 | | - 'List the first 50 deleted revisions in the Category and Category talk namespaces', |
| 232 | | - ' api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=14|15', |
| | 224 | + 'List the first 50 deleted revisions', |
| | 225 | + ' api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50', |
| 233 | 226 | 'List the last deleted revisions of Main Page and Talk:Main Page, with content:', |
| 234 | 227 | ' api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content' |
| 235 | 228 | ); |
| Index: trunk/phase3/includes/api/ApiQueryBase.php |
| — | — | @@ -111,8 +111,11 @@ |
| 112 | 112 | if (!is_null($end)) |
| 113 | 113 | $this->addWhere($field . $before . $db->addQuotes($end)); |
| 114 | 114 | |
| | 115 | + $order = $field . ($isDirNewer ? '' : ' DESC'); |
| 115 | 116 | if (!isset($this->options['ORDER BY'])) |
| 116 | | - $this->addOption('ORDER BY', $field . ($isDirNewer ? '' : ' DESC')); |
| | 117 | + $this->addOption('ORDER BY', $order); |
| | 118 | + else |
| | 119 | + $this->addOption('ORDER BY', $this->options['ORDER BY'] . ', ' . $order); |
| 117 | 120 | } |
| 118 | 121 | |
| 119 | 122 | protected function addOption($name, $value = null) { |
| — | — | @@ -134,6 +137,18 @@ |
| 135 | 138 | return $res; |
| 136 | 139 | } |
| 137 | 140 | |
| | 141 | + protected function checkRowCount() { |
| | 142 | + $db = $this->getDB(); |
| | 143 | + $this->profileDBIn(); |
| | 144 | + $rowcount = $db->estimateRowCount($this->tables, $this->fields, $this->where, __METHOD__, $this->options); |
| | 145 | + $this->profileDBOut(); |
| | 146 | + |
| | 147 | + global $wgAPIMaxDBRows; |
| | 148 | + if($rowcount > $wgAPIMaxDBRows) |
| | 149 | + return false; |
| | 150 | + return true; |
| | 151 | + } |
| | 152 | + |
| 138 | 153 | public static function addTitleInfo(&$arr, $title, $prefix='') { |
| 139 | 154 | $arr[$prefix . 'ns'] = intval($title->getNamespace()); |
| 140 | 155 | $arr[$prefix . 'title'] = $title->getPrefixedText(); |
| Index: trunk/phase3/includes/api/ApiQueryUserContributions.php |
| — | — | @@ -62,10 +62,6 @@ |
| 63 | 63 | |
| 64 | 64 | if(isset($this->params['userprefix'])) |
| 65 | 65 | { |
| 66 | | - global $wgAPIUCUserPrefixMinLength; |
| 67 | | - if(strlen($this->params['userprefix']) < $wgAPIUCUserPrefixMinLength) |
| 68 | | - $this->dieUsage("User prefixes must be at least $wgAPIUCUserPrefixMinLength characters", 'userprefix-tooshort'); |
| 69 | | - |
| 70 | 66 | $this->prefixMode = true; |
| 71 | 67 | $this->userprefix = $this->params['userprefix']; |
| 72 | 68 | } |
| — | — | @@ -145,6 +141,9 @@ |
| 146 | 142 | else |
| 147 | 143 | $this->addWhereFld( 'rev_user_text', $this->usernames ); |
| 148 | 144 | // ... and in the specified timeframe. |
| | 145 | + // Ensure the same sort order for rev_user_text and rev_timestamp |
| | 146 | + // so our query is indexed |
| | 147 | + $this->addWhereRange('rev_user_text', $this->params['dir'], null, null); |
| 149 | 148 | $this->addWhereRange('rev_timestamp', |
| 150 | 149 | $this->params['dir'], $this->params['start'], $this->params['end'] ); |
| 151 | 150 | $this->addWhereFld('page_namespace', $this->params['namespace']); |
| Index: trunk/phase3/includes/DefaultSettings.php |
| — | — | @@ -2877,10 +2877,10 @@ |
| 2878 | 2878 | $wgAPIModules = array(); |
| 2879 | 2879 | |
| 2880 | 2880 | /** |
| 2881 | | - * Minimum length of list=usercontribs's ucuserprefix parameter |
| 2882 | | - * Setting this to a low value can open DOS windows on large wikis |
| | 2881 | + * Maximum amount of rows to scan in a DB query in the API |
| | 2882 | + * The default value is generally fine |
| 2883 | 2883 | */ |
| 2884 | | -$wgAPIUCUserPrefixMinLength = 3; |
| | 2884 | +$wgAPIMaxDBRows = 5000; |
| 2885 | 2885 | |
| 2886 | 2886 | /** |
| 2887 | 2887 | * Parser test suite files to be run by parserTests.php when no specific |
| Index: trunk/phase3/RELEASE-NOTES |
| — | — | @@ -167,6 +167,7 @@ |
| 168 | 168 | * Added inprop=talkid,subjectid to prop=info |
| 169 | 169 | * Added help text message that specifies whether a module is POST-only |
| 170 | 170 | * Added createonly parameter to action=edit |
| | 171 | +* Replaced $wgAPIUCUserPrefixMinLength by the more generic $wgAPIMaxDBRows |
| 171 | 172 | |
| 172 | 173 | === Languages updated in 1.13 === |
| 173 | 174 | |