Set default for unused variable in ApiFormatBase
[lhc/web/wiklou.git] / includes / api / ApiPageSet.php
index 20444d0..3bdecaa 100644 (file)
@@ -53,7 +53,10 @@ class ApiPageSet extends ApiBase {
 
        private $mAllPages = array(); // [ns][dbkey] => page_id or negative when missing
        private $mTitles = array();
+       private $mGoodAndMissingPages = array(); // [ns][dbkey] => page_id or negative when missing
+       private $mGoodPages = array(); // [ns][dbkey] => page_id
        private $mGoodTitles = array();
+       private $mMissingPages = array(); // [ns][dbkey] => fake page_id
        private $mMissingTitles = array();
        private $mInvalidTitles = array();
        private $mMissingPageIDs = array();
@@ -61,6 +64,7 @@ class ApiPageSet extends ApiBase {
        private $mSpecialTitles = array();
        private $mNormalizedTitles = array();
        private $mInterwikiTitles = array();
+       /** @var Title[] */
        private $mPendingRedirectIDs = array();
        private $mConvertedTitles = array();
        private $mGoodRevIDs = array();
@@ -68,9 +72,7 @@ class ApiPageSet extends ApiBase {
        private $mFakePageId = -1;
        private $mCacheMode = 'public';
        private $mRequestedPageFields = array();
-       /**
-        * @var int
-        */
+       /** @var int */
        private $mDefaultNamespace = NS_MAIN;
 
        /**
@@ -344,6 +346,14 @@ class ApiPageSet extends ApiBase {
                return count( $this->mTitles );
        }
 
+       /**
+        * Returns an array [ns][dbkey] => page_id for all good titles.
+        * @return array
+        */
+       public function getGoodTitlesByNamespace() {
+               return $this->mGoodPages;
+       }
+
        /**
         * Title objects that were found in the database.
         * @return Title[] Array page_id (int) => Title (obj)
@@ -360,6 +370,15 @@ class ApiPageSet extends ApiBase {
                return count( $this->mGoodTitles );
        }
 
+       /**
+        * Returns an array [ns][dbkey] => fake_page_id for all missing titles.
+        * fake_page_id is a unique negative number.
+        * @return array
+        */
+       public function getMissingTitlesByNamespace() {
+               return $this->mMissingPages;
+       }
+
        /**
         * Title objects that were NOT found in the database.
         * The array's index will be negative for each item
@@ -369,6 +388,22 @@ class ApiPageSet extends ApiBase {
                return $this->mMissingTitles;
        }
 
+       /**
+        * Returns an array [ns][dbkey] => page_id for all good and missing titles.
+        * @return array
+        */
+       public function getGoodAndMissingTitlesByNamespace() {
+               return $this->mGoodAndMissingPages;
+       }
+
+       /**
+        * Title objects for good and missing titles.
+        * @return array
+        */
+       public function getGoodAndMissingTitles() {
+               return $this->mGoodTitles + $this->mMissingTitles;
+       }
+
        /**
         * Titles that were deemed invalid by Title::newFromText()
         * The array's index will be unique and negative for each item
@@ -389,7 +424,7 @@ class ApiPageSet extends ApiBase {
        /**
         * Get a list of redirect resolutions - maps a title to its redirect
         * target, as an array of output-ready arrays
-        * @return array
+        * @return Title[]
         */
        public function getRedirectTitles() {
                return $this->mRedirectTitles;
@@ -598,7 +633,7 @@ class ApiPageSet extends ApiBase {
 
        /**
         * Get the list of titles with negative namespace
-        * @return array Title
+        * @return Title[]
         */
        public function getSpecialTitles() {
                return $this->mSpecialTitles;
@@ -668,6 +703,8 @@ class ApiPageSet extends ApiBase {
                if ( $this->mResolveRedirects && $row->page_is_redirect == '1' ) {
                        $this->mPendingRedirectIDs[$pageId] = $title;
                } else {
+                       $this->mGoodPages[$row->page_namespace][$row->page_title] = $pageId;
+                       $this->mGoodAndMissingPages[$row->page_namespace][$row->page_title] = $pageId;
                        $this->mGoodTitles[$pageId] = $title;
                }
 
@@ -804,6 +841,8 @@ class ApiPageSet extends ApiBase {
                                        foreach ( array_keys( $dbkeys ) as $dbkey ) {
                                                $title = Title::makeTitle( $ns, $dbkey );
                                                $this->mAllPages[$ns][$dbkey] = $this->mFakePageId;
+                                               $this->mMissingPages[$ns][$dbkey] = $this->mFakePageId;
+                                               $this->mGoodAndMissingPages[$ns][$dbkey] = $this->mFakePageId;
                                                $this->mMissingTitles[$this->mFakePageId] = $title;
                                                $this->mFakePageId--;
                                                $this->mTitles[] = $title;
@@ -1168,21 +1207,4 @@ class ApiPageSet extends ApiBase {
                        ),
                );
        }
-
-       public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array(
-                               'code' => 'multisource',
-                               'info' => "Cannot use 'pageids' at the same time as 'dataSource'"
-                       ),
-                       array(
-                               'code' => 'multisource',
-                               'info' => "Cannot use 'revids' at the same time as 'dataSource'"
-                       ),
-                       array(
-                               'code' => 'badgenerator',
-                               'info' => 'Module $generatorName cannot be used as a generator'
-                       ),
-               ) );
-       }
 }