- $result->addValue(array (
- 'query',
- 'pages'
- ), $pageid, $pageInfo);
- }
-
- // Get properties for missing titles if requested
- if(!is_null($params['token']) || $fld_protection || $fld_talkid || $fld_subjectid ||
- $fld_url || $fld_readable)
- {
- $res = &$result->getData();
- foreach($missing as $pageid => $title) {
- if(!is_null($params['token']))
- {
- $tokenFunctions = $this->getTokenFunctions();
- $res['query']['pages'][$pageid]['starttimestamp'] = wfTimestamp(TS_ISO_8601, time());
- foreach($params['token'] as $t)
- {
- $val = call_user_func($tokenFunctions[$t], $pageid, $title);
- if($val !== false)
- $res['query']['pages'][$pageid][$t . 'token'] = $val;
- }
- }
- if($fld_protection)
- {
- // Apparently the XML formatting code doesn't like array(null)
- // This is painful to fix, so we'll just work around it
- if(isset($prottitles[$title->getNamespace()][$title->getDBkey()]))
- $res['query']['pages'][$pageid]['protection'] = $prottitles[$title->getNamespace()][$title->getDBkey()];
- else
- $res['query']['pages'][$pageid]['protection'] = array();
- $result->setIndexedTagName($res['query']['pages'][$pageid]['protection'], 'pr');
+ if ( count( $others ) ) {
+ // Non-images: check templatelinks
+ $lb = new LinkBatch( $others );
+ $this->resetQueryParams();
+ $this->addTables( array( 'page_restrictions', 'page', 'templatelinks' ) );
+ $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
+ 'page_title', 'page_namespace',
+ 'tl_title', 'tl_namespace' ) );
+ $this->addWhere( $lb->constructSet( 'tl', $db ) );
+ $this->addWhere( 'pr_page = page_id' );
+ $this->addWhere( 'pr_page = tl_from' );
+ $this->addWhereFld( 'pr_cascade', 1 );
+
+ $res = $this->select( __METHOD__ );
+ foreach ( $res as $row ) {
+ $source = Title::makeTitle( $row->page_namespace, $row->page_title );
+ $this->protections[$row->tl_namespace][$row->tl_title][] = array(
+ 'type' => $row->pr_type,
+ 'level' => $row->pr_level,
+ 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ),
+ 'source' => $source->getPrefixedText()
+ );
+ }
+ }
+
+ if ( count( $images ) ) {
+ // Images: check imagelinks
+ $this->resetQueryParams();
+ $this->addTables( array( 'page_restrictions', 'page', 'imagelinks' ) );
+ $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
+ 'page_title', 'page_namespace', 'il_to' ) );
+ $this->addWhere( 'pr_page = page_id' );
+ $this->addWhere( 'pr_page = il_from' );
+ $this->addWhereFld( 'pr_cascade', 1 );
+ $this->addWhereFld( 'il_to', $images );
+
+ $res = $this->select( __METHOD__ );
+ foreach ( $res as $row ) {
+ $source = Title::makeTitle( $row->page_namespace, $row->page_title );
+ $this->protections[NS_FILE][$row->il_to][] = array(
+ 'type' => $row->pr_type,
+ 'level' => $row->pr_level,
+ 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ),
+ 'source' => $source->getPrefixedText()
+ );
+ }
+ }
+ }
+
+ /**
+ * Get talk page IDs (if requested) and subject page IDs (if requested)
+ * and put them in $talkids and $subjectids
+ */
+ private function getTSIDs() {
+ $getTitles = $this->talkids = $this->subjectids = array();
+
+ foreach ( $this->everything as $t ) {
+ if ( MWNamespace::isTalk( $t->getNamespace() ) ) {
+ if ( $this->fld_subjectid ) {
+ $getTitles[] = $t->getSubjectPage();