Index: trunk/phase3/includes/api/ApiQueryExtLinksUsage.php |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | |
131 | 131 | if (is_null($resultPageSet)) { |
132 | 132 | $result = $this->getResult(); |
133 | | - $result->setIndexedTagName($data, 'p'); |
| 133 | + $result->setIndexedTagName($data, $this->getModulePrefix()); |
134 | 134 | $result->addValue('query', $this->getModuleName(), $data); |
135 | 135 | } |
136 | 136 | } |
Index: trunk/phase3/includes/api/ApiQueryAllpages.php |
— | — | @@ -55,8 +55,8 @@ |
56 | 56 | $db = $this->getDB(); |
57 | 57 | |
58 | 58 | $params = $this->extractRequestParams(); |
59 | | - |
60 | | - $this->addTables('page'); |
| 59 | + |
| 60 | + // Page filters |
61 | 61 | if (!$this->addWhereIf('page_is_redirect = 1', $params['filterredir'] === 'redirects')) |
62 | 62 | $this->addWhereIf('page_is_redirect = 0', $params['filterredir'] === 'nonredirects'); |
63 | 63 | $this->addWhereFld('page_namespace', $params['namespace']); |
— | — | @@ -65,6 +65,39 @@ |
66 | 66 | if (isset ($params['prefix'])) |
67 | 67 | $this->addWhere("page_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); |
68 | 68 | |
| 69 | + $forceNameTitleIndex = true; |
| 70 | + if (isset ($params['minsize'])) { |
| 71 | + $this->addWhere('page_len>=' . intval($params['minsize'])); |
| 72 | + $forceNameTitleIndex = false; |
| 73 | + } |
| 74 | + |
| 75 | + if (isset ($params['maxsize'])) { |
| 76 | + $this->addWhere('page_len<=' . intval($params['maxsize'])); |
| 77 | + $forceNameTitleIndex = false; |
| 78 | + } |
| 79 | + |
| 80 | + // Page protection filtering |
| 81 | + if (isset ($params['prtype'])) { |
| 82 | + $this->addTables('page_restrictions'); |
| 83 | + $this->addWhere('page_id=pr_page'); |
| 84 | + $this->addWhere('pr_expiry>' . $db->addQuotes($db->timestamp())); |
| 85 | + $this->addWhereFld('pr_type', $params['prtype']); |
| 86 | + |
| 87 | + $prlevel = $params['prlevel']; |
| 88 | + if (!is_null($prlevel) && $prlevel != '' && $prlevel != '*') |
| 89 | + $this->addWhereFld('pr_level', $prlevel); |
| 90 | + |
| 91 | + $forceNameTitleIndex = false; |
| 92 | + |
| 93 | + } else if (isset ($params['prlevel'])) { |
| 94 | + $this->dieUsage('prlevel may not be used without prtype', 'params'); |
| 95 | + } |
| 96 | + |
| 97 | + $this->addTables('page'); |
| 98 | + if ($forceNameTitleIndex) |
| 99 | + $this->addOption('USE INDEX', 'name_title'); |
| 100 | + |
| 101 | + |
69 | 102 | if (is_null($resultPageSet)) { |
70 | 103 | $this->addFields(array ( |
71 | 104 | 'page_id', |
— | — | @@ -75,7 +108,6 @@ |
76 | 109 | $this->addFields($resultPageSet->getPageTableFields()); |
77 | 110 | } |
78 | 111 | |
79 | | - $this->addOption('USE INDEX', 'name_title'); |
80 | 112 | $limit = $params['limit']; |
81 | 113 | $this->addOption('LIMIT', $limit+1); |
82 | 114 | $this->addOption('ORDER BY', 'page_namespace, page_title'); |
— | — | @@ -112,12 +144,14 @@ |
113 | 145 | } |
114 | 146 | |
115 | 147 | protected function getAllowedParams() { |
| 148 | + global $wgRestrictionTypes, $wgRestrictionLevels; |
| 149 | + |
116 | 150 | return array ( |
117 | 151 | 'from' => null, |
118 | 152 | 'prefix' => null, |
119 | 153 | 'namespace' => array ( |
120 | 154 | ApiBase :: PARAM_DFLT => 0, |
121 | | - ApiBase :: PARAM_TYPE => 'namespace' |
| 155 | + ApiBase :: PARAM_TYPE => 'namespace', |
122 | 156 | ), |
123 | 157 | 'filterredir' => array ( |
124 | 158 | ApiBase :: PARAM_DFLT => 'all', |
— | — | @@ -127,6 +161,18 @@ |
128 | 162 | 'nonredirects' |
129 | 163 | ) |
130 | 164 | ), |
| 165 | + 'minsize' => array ( |
| 166 | + ApiBase :: PARAM_TYPE => 'integer', |
| 167 | + ), |
| 168 | + 'maxsize' => array ( |
| 169 | + ApiBase :: PARAM_TYPE => 'integer', |
| 170 | + ), |
| 171 | + 'prtype' => array ( |
| 172 | + ApiBase :: PARAM_TYPE => $wgRestrictionTypes, |
| 173 | + ), |
| 174 | + 'prlevel' => array ( |
| 175 | + ApiBase :: PARAM_TYPE => $wgRestrictionLevels, |
| 176 | + ), |
131 | 177 | 'limit' => array ( |
132 | 178 | ApiBase :: PARAM_DFLT => 10, |
133 | 179 | ApiBase :: PARAM_TYPE => 'limit', |
— | — | @@ -143,6 +189,10 @@ |
144 | 190 | 'prefix' => 'Search for all page titles that begin with this value.', |
145 | 191 | 'namespace' => 'The namespace to enumerate.', |
146 | 192 | 'filterredir' => 'Which pages to list.', |
| 193 | + 'minsize' => 'Limit to pages with at least this many bytes', |
| 194 | + 'maxsize' => 'Limit to pages with at most this many bytes', |
| 195 | + 'prtype' => 'Limit to protected pages only', |
| 196 | + 'prlevel' => 'The protection level (must be used with apprtype= parameter)', |
147 | 197 | 'limit' => 'How many total pages to return.' |
148 | 198 | ); |
149 | 199 | } |