Index: trunk/phase3/includes/api/ApiQueryAllpages.php |
— | — | @@ -111,30 +111,38 @@ |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Page protection filtering |
115 | | - if ( !empty( $params['prtype'] ) ) { |
| 115 | + if ( count( $params['prtype'] ) || $params['prexpiry'] != 'all' ) { |
116 | 116 | $this->addTables( 'page_restrictions' ); |
117 | 117 | $this->addWhere( 'page_id=pr_page' ); |
118 | 118 | $this->addWhere( 'pr_expiry>' . $db->addQuotes( $db->timestamp() ) ); |
119 | | - $this->addWhereFld( 'pr_type', $params['prtype'] ); |
120 | 119 | |
121 | | - if ( isset( $params['prlevel'] ) ) { |
122 | | - // Remove the empty string and '*' from the prlevel array |
123 | | - $prlevel = array_diff( $params['prlevel'], array( '', '*' ) ); |
| 120 | + if ( count( $params['prtype'] ) ) { |
| 121 | + $this->addWhereFld( 'pr_type', $params['prtype'] ); |
124 | 122 | |
125 | | - if ( !empty( $prlevel ) ) { |
126 | | - $this->addWhereFld( 'pr_level', $prlevel ); |
| 123 | + if ( isset( $params['prlevel'] ) ) { |
| 124 | + // Remove the empty string and '*' from the prlevel array |
| 125 | + $prlevel = array_diff( $params['prlevel'], array( '', '*' ) ); |
| 126 | + |
| 127 | + if ( count( $prlevel ) ) { |
| 128 | + $this->addWhereFld( 'pr_level', $prlevel ); |
| 129 | + } |
127 | 130 | } |
| 131 | + if ( $params['prfiltercascade'] == 'cascading' ) { |
| 132 | + $this->addWhereFld( 'pr_cascade', 1 ); |
| 133 | + } elseif ( $params['prfiltercascade'] == 'noncascading' ) { |
| 134 | + $this->addWhereFld( 'pr_cascade', 0 ); |
| 135 | + } |
| 136 | + |
| 137 | + $this->addOption( 'DISTINCT' ); |
128 | 138 | } |
129 | | - if ( $params['prfiltercascade'] == 'cascading' ) { |
130 | | - $this->addWhereFld( 'pr_cascade', 1 ); |
131 | | - } elseif ( $params['prfiltercascade'] == 'noncascading' ) { |
132 | | - $this->addWhereFld( 'pr_cascade', 0 ); |
| 139 | + $forceNameTitleIndex = false; |
| 140 | + |
| 141 | + if ( $params['prexpiry'] == 'indefinite' ) { |
| 142 | + $this->addWhere( "pr_expiry = 'infinity' OR pr_expiry IS NULL" ); |
| 143 | + } elseif ( $params['prexpiry'] == 'definite' ) { |
| 144 | + $this->addWhere( "pr_expiry != 'infinity'" ); |
133 | 145 | } |
134 | 146 | |
135 | | - $this->addOption( 'DISTINCT' ); |
136 | | - |
137 | | - $forceNameTitleIndex = false; |
138 | | - |
139 | 147 | } elseif ( isset( $params['prlevel'] ) ) { |
140 | 148 | $this->dieUsage( 'prlevel may not be used without prtype', 'params' ); |
141 | 149 | } |
— | — | @@ -256,7 +264,15 @@ |
257 | 265 | 'all' |
258 | 266 | ), |
259 | 267 | ApiBase::PARAM_DFLT => 'all' |
260 | | - ) |
| 268 | + ), |
| 269 | + 'prexpiry' => array( |
| 270 | + ApiBase::PARAM_TYPE => array( |
| 271 | + 'indefinite', |
| 272 | + 'definite', |
| 273 | + 'all' |
| 274 | + ), |
| 275 | + ApiBase::PARAM_DFLT => 'all' |
| 276 | + ), |
261 | 277 | ); |
262 | 278 | } |
263 | 279 | |
— | — | @@ -275,7 +291,13 @@ |
276 | 292 | 'prlevel' => "The protection level (must be used with {$p}prtype= parameter)", |
277 | 293 | 'prfiltercascade' => "Filter protections based on cascadingness (ignored when {$p}prtype isn't set)", |
278 | 294 | 'filterlanglinks' => 'Filter based on whether a page has langlinks', |
279 | | - 'limit' => 'How many total pages to return.' |
| 295 | + 'limit' => 'How many total pages to return.', |
| 296 | + 'prexpiry' => array( |
| 297 | + 'Which protection expiry to filter the page on', |
| 298 | + ' indefinite - Get only pages with indefinite protection expiry', |
| 299 | + ' definite - Get only pages with a definite (specific) protection expiry', |
| 300 | + ' all - Get pages with any protections expiry' |
| 301 | + ), |
280 | 302 | ); |
281 | 303 | } |
282 | 304 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -346,6 +346,7 @@ |
347 | 347 | * YAML API output is now 1.2 compliant, using JSON as the formatter |
348 | 348 | * (bug 28672) give information about misermode on api |
349 | 349 | * (bug 28558) Add iw_api and iw_wikiid to meta=siteinfo&siprop=interwikimap |
| 350 | +* (bug 26882) Allow listing of indefinite protections with the api |
350 | 351 | |
351 | 352 | === Languages updated in 1.18 === |
352 | 353 | |