From 43b1c36ab3ec339f4d8ccb0c428c50ae9cfd78dc Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 8 Jun 2012 11:02:46 +0200 Subject: [PATCH] avoid Title::exist/getArticleId in ApiQueryInfo::extractPageInfo For missing title the pageid is not set inside the Title objects, but the pageid is given to that method, so it is better to use that pageid to check for exist or to use the pageid, instead of using the Title method. Change-Id: I07db242eb37731610ac7a83acdb5e6adfc2951aa --- includes/api/ApiQueryInfo.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index e5db4d8620..e611ea8167 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -337,7 +337,10 @@ class ApiQueryInfo extends ApiQueryBase { */ private function extractPageInfo( $pageid, $title ) { $pageInfo = array(); - if ( $title->exists() ) { + $titleExists = $pageid > 0; //$title->exists() needs pageid, which is not set for all title objects + $ns = $title->getNamespace(); + $dbkey = $title->getDBkey(); + if ( $titleExists ) { global $wgDisableCounters; $pageInfo['touched'] = wfTimestamp( TS_ISO_8601, $this->pageTouched[$pageid] ); @@ -370,23 +373,23 @@ class ApiQueryInfo extends ApiQueryBase { if ( $this->fld_protection ) { $pageInfo['protection'] = array(); - if ( isset( $this->protections[$title->getNamespace()][$title->getDBkey()] ) ) { + if ( isset( $this->protections[$ns][$dbkey] ) ) { $pageInfo['protection'] = - $this->protections[$title->getNamespace()][$title->getDBkey()]; + $this->protections[$ns][$dbkey]; } $this->getResult()->setIndexedTagName( $pageInfo['protection'], 'pr' ); } - if ( $this->fld_watched && isset( $this->watched[$title->getNamespace()][$title->getDBkey()] ) ) { + if ( $this->fld_watched && isset( $this->watched[$ns][$dbkey] ) ) { $pageInfo['watched'] = ''; } - if ( $this->fld_talkid && isset( $this->talkids[$title->getNamespace()][$title->getDBkey()] ) ) { - $pageInfo['talkid'] = $this->talkids[$title->getNamespace()][$title->getDBkey()]; + if ( $this->fld_talkid && isset( $this->talkids[$ns][$dbkey] ) ) { + $pageInfo['talkid'] = $this->talkids[$ns][$dbkey]; } - if ( $this->fld_subjectid && isset( $this->subjectids[$title->getNamespace()][$title->getDBkey()] ) ) { - $pageInfo['subjectid'] = $this->subjectids[$title->getNamespace()][$title->getDBkey()]; + if ( $this->fld_subjectid && isset( $this->subjectids[$ns][$dbkey] ) ) { + $pageInfo['subjectid'] = $this->subjectids[$ns][$dbkey]; } if ( $this->fld_url ) { @@ -398,7 +401,7 @@ class ApiQueryInfo extends ApiQueryBase { } if ( $this->fld_preload ) { - if ( $title->exists() ) { + if ( $titleExists ) { $pageInfo['preload'] = ''; } else { $text = null; @@ -409,8 +412,8 @@ class ApiQueryInfo extends ApiQueryBase { } if ( $this->fld_displaytitle ) { - if ( isset( $this->displaytitles[$title->getArticleID()] ) ) { - $pageInfo['displaytitle'] = $this->displaytitles[$title->getArticleID()]; + if ( isset( $this->displaytitles[$pageid] ) ) { + $pageInfo['displaytitle'] = $this->displaytitles[$pageid]; } else { $pageInfo['displaytitle'] = $title->getPrefixedText(); } -- 2.20.1