Index: trunk/phase3/includes/api/ApiQueryInfo.php |
— | — | @@ -173,13 +173,71 @@ |
174 | 174 | $res = $this->select(__METHOD__); |
175 | 175 | $prottitles = array(); |
176 | 176 | while($row = $db->fetchObject($res)) { |
177 | | - $prottitles[$row->pt_namespace][$row->pt_title] = array( |
| 177 | + $prottitles[$row->pt_namespace][$row->pt_title][] = array( |
178 | 178 | 'type' => 'create', |
179 | 179 | 'level' => $row->pt_create_perm, |
180 | 180 | 'expiry' => Block::decodeExpiry($row->pt_expiry, TS_ISO_8601) |
181 | 181 | ); |
182 | 182 | } |
183 | 183 | $db->freeResult($res); |
| 184 | + |
| 185 | + $images = array(); |
| 186 | + $others = array(); |
| 187 | + foreach ($missing as $title) |
| 188 | + if ($title->getNamespace() == NS_IMAGE) |
| 189 | + $images[] = $title->getDbKey(); |
| 190 | + else |
| 191 | + $others[] = $title; |
| 192 | + |
| 193 | + if (count($others) != 0) { |
| 194 | + $lb = new LinkBatch($others); |
| 195 | + $this->resetQueryParams(); |
| 196 | + $this->addTables(array('page_restrictions', 'page', 'templatelinks')); |
| 197 | + $this->addFields(array('pr_type', 'pr_level', 'pr_expiry', |
| 198 | + 'page_title', 'page_namespace', |
| 199 | + 'tl_title', 'tl_namespace')); |
| 200 | + $this->addWhere($lb->constructSet('tl', $db)); |
| 201 | + $this->addWhere('pr_page = page_id'); |
| 202 | + $this->addWhere('pr_page = tl_from'); |
| 203 | + $this->addWhereFld('pr_cascade', 1); |
| 204 | + |
| 205 | + $res = $this->select(__METHOD__); |
| 206 | + while($row = $db->fetchObject($res)) { |
| 207 | + $source = Title::makeTitle($row->page_namespace, $row->page_title); |
| 208 | + $a = array( |
| 209 | + 'type' => $row->pr_type, |
| 210 | + 'level' => $row->pr_level, |
| 211 | + 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ), |
| 212 | + 'source' => $source->getPrefixedText() |
| 213 | + ); |
| 214 | + $prottitles[$row->tl_namespace][$row->tl_title][] = $a; |
| 215 | + } |
| 216 | + $db->freeResult($res); |
| 217 | + } |
| 218 | + |
| 219 | + if (count($images) != 0) { |
| 220 | + $this->resetQueryParams(); |
| 221 | + $this->addTables(array('page_restrictions', 'page', 'imagelinks')); |
| 222 | + $this->addFields(array('pr_type', 'pr_level', 'pr_expiry', |
| 223 | + 'page_title', 'page_namespace', 'il_to')); |
| 224 | + $this->addWhere('pr_page = page_id'); |
| 225 | + $this->addWhere('pr_page = il_from'); |
| 226 | + $this->addWhereFld('pr_cascade', 1); |
| 227 | + $this->addWhereFld('il_to', $images); |
| 228 | + |
| 229 | + $res = $this->select(__METHOD__); |
| 230 | + while($row = $db->fetchObject($res)) { |
| 231 | + $source = Title::makeTitle($row->page_namespace, $row->page_title); |
| 232 | + $a = array( |
| 233 | + 'type' => $row->pr_type, |
| 234 | + 'level' => $row->pr_level, |
| 235 | + 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ), |
| 236 | + 'source' => $source->getPrefixedText() |
| 237 | + ); |
| 238 | + $prottitles[NS_IMAGE][$row->il_to][] = $a; |
| 239 | + } |
| 240 | + $db->freeResult($res); |
| 241 | + } |
184 | 242 | } |
185 | 243 | |
186 | 244 | // Run the talkid/subjectid query |
— | — | @@ -307,7 +365,7 @@ |
308 | 366 | // Apparently the XML formatting code doesn't like array(null) |
309 | 367 | // This is painful to fix, so we'll just work around it |
310 | 368 | if(isset($prottitles[$title->getNamespace()][$title->getDBkey()])) |
311 | | - $res['query']['pages'][$pageid]['protection'][] = $prottitles[$title->getNamespace()][$title->getDBkey()]; |
| 369 | + $res['query']['pages'][$pageid]['protection'] = $prottitles[$title->getNamespace()][$title->getDBkey()]; |
312 | 370 | else |
313 | 371 | $res['query']['pages'][$pageid]['protection'] = array(); |
314 | 372 | $result->setIndexedTagName($res['query']['pages'][$pageid]['protection'], 'pr'); |