Index: trunk/phase3/includes/api/ApiQueryCategories.php |
— | — | @@ -81,6 +81,19 @@ |
82 | 82 | |
83 | 83 | $this->addTables('categorylinks'); |
84 | 84 | $this->addWhereFld('cl_from', array_keys($this->getPageSet()->getGoodTitles())); |
| 85 | + if(!is_null($params['categories'])) |
| 86 | + { |
| 87 | + $cats = array(); |
| 88 | + foreach($params['categories'] as $cat) |
| 89 | + { |
| 90 | + $title = Title::newFromText($cat); |
| 91 | + if($title->getNamespace() != NS_CATEGORY) |
| 92 | + $this->setWarning("``$cat'' is not a category"); |
| 93 | + else |
| 94 | + $cats[] = $title->getDBkey(); |
| 95 | + } |
| 96 | + $this->addWhereFld('cl_to', $cats); |
| 97 | + } |
85 | 98 | if(!is_null($params['continue'])) { |
86 | 99 | $cont = explode('|', $params['continue']); |
87 | 100 | if(count($cont) != 2) |
— | — | @@ -112,6 +125,7 @@ |
113 | 126 | $this->addWhere(array('pp_propname IS NULL')); |
114 | 127 | } |
115 | 128 | |
| 129 | + $this->addOption('USE INDEX', array('categorylinks' => 'cl_from')); |
116 | 130 | # Don't order by cl_from if it's constant in the WHERE clause |
117 | 131 | if(count($this->getPageSet()->getGoodTitles()) == 1) |
118 | 132 | $this->addOption('ORDER BY', 'cl_to'); |
— | — | @@ -202,6 +216,9 @@ |
203 | 217 | ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
204 | 218 | ), |
205 | 219 | 'continue' => null, |
| 220 | + 'categories' => array( |
| 221 | + ApiBase :: PARAM_ISMULTI => true, |
| 222 | + ), |
206 | 223 | ); |
207 | 224 | } |
208 | 225 | |
— | — | @@ -211,6 +228,7 @@ |
212 | 229 | 'limit' => 'How many categories to return', |
213 | 230 | 'show' => 'Which kind of categories to show', |
214 | 231 | 'continue' => 'When more results are available, use this to continue', |
| 232 | + 'categories' => 'Only list these categories. Useful for checking whether a certain page is in a certain category', |
215 | 233 | ); |
216 | 234 | } |
217 | 235 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -49,6 +49,7 @@ |
50 | 50 | incorrectly |
51 | 51 | * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions |
52 | 52 | and listing all deleted pages possible |
| 53 | +* (bug 16844) Added clcategories parameter to prop=categories |
53 | 54 | |
54 | 55 | === Languages updated in 1.15 === |
55 | 56 | |