Checking permissions for $wgUser while doing an edit with another user is not a good...
[lhc/web/wiklou.git] / includes / api / ApiPageSet.php
index ada8543..d13df81 100644 (file)
@@ -1,10 +1,9 @@
 <?php
-
 /**
- * Created on Sep 24, 2006
- *
  * API for MediaWiki 1.8+
  *
+ * Created on Sep 24, 2006
+ *
  * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
@@ -21,6 +20,8 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
  */
 
 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -80,7 +81,7 @@ class ApiPageSet extends ApiQueryBase {
                if ( $resolveRedirects ) {
                        $this->mPendingRedirectIDs = array();
                }
-               
+
                $this->mConvertTitles = $convertTitles;
                $this->mConvertedTitles = array();
 
@@ -225,12 +226,12 @@ class ApiPageSet extends ApiQueryBase {
        public function getNormalizedTitles() {
                return $this->mNormalizedTitles;
        }
-       
+
        /**
         * Get a list of title conversions - maps a title to its converted
         * version.
         * @return array raw_prefixed_title (string) => prefixed_title (string)
-        */     
+        */
        public function getConvertedTitles() {
                return $this->mConvertedTitles;
        }
@@ -259,7 +260,7 @@ class ApiPageSet extends ApiQueryBase {
        public function getMissingRevisionIDs() {
                return $this->mMissingRevIDs;
        }
-       
+
        /**
         * Get the list of titles with negative namespace
         * @return array Title
@@ -346,7 +347,7 @@ class ApiPageSet extends ApiQueryBase {
        /**
         * Populate this PageSet from a rowset returned from the database
         * @param $db Database object
-        * @param $queryResult Query result object
+        * @param $queryResult ResultWrapper Query result object
         */
        public function populateFromQueryResult( $db, $queryResult ) {
                $this->profileIn();
@@ -467,7 +468,7 @@ class ApiPageSet extends ApiQueryBase {
         * Iterate through the result of the query on 'page' table,
         * and for each row create and store title object and save any extra fields requested.
         * @param $db Database
-        * @param $res DB Query result
+        * @param $res ResultWrapper DB Query result
         * @param $remaining array of either pageID or ns/title elements (optional).
         *        If given, any missing items will go to $mMissingPageIDs and $mMissingTitles
         * @param $processTitles bool Must be provided together with $remaining.
@@ -500,7 +501,7 @@ class ApiPageSet extends ApiQueryBase {
                        if ( $processTitles ) {
                                // The remaining titles in $remaining are non-existent pages
                                foreach ( $remaining as $ns => $dbkeys ) {
-                                       foreach ( $dbkeys as $dbkey => $unused ) {
+                                       foreach ( array_keys( $dbkeys ) as $dbkey ) {
                                                $title = Title::makeTitle( $ns, $dbkey );
                                                $this->mAllPages[$ns][$dbkey] = $this->mFakePageId;
                                                $this->mMissingTitles[$this->mFakePageId] = $title;
@@ -667,7 +668,7 @@ class ApiPageSet extends ApiQueryBase {
                                continue; // There's nothing else we can do
                        }
                        $unconvertedTitle = $titleObj->getPrefixedText();
-                       $titleWasConverted = false;                     
+                       $titleWasConverted = false;
                        $iw = $titleObj->getInterwiki();
                        if ( strval( $iw ) !== '' ) {
                                // This title is an interwiki link.
@@ -677,14 +678,14 @@ class ApiPageSet extends ApiQueryBase {
                                global $wgContLang;
                                if ( $this->mConvertTitles &&
                                                count( $wgContLang->getVariants() ) > 1  &&
-                                               $titleObj->getArticleID() == 0 ) {
-                                       // Language::findVariantLink will modify titleObj into 
+                                               !$titleObj->exists() ) {
+                                       // Language::findVariantLink will modify titleObj into
                                        // the canonical variant if possible
                                        $wgContLang->findVariantLink( $title, $titleObj );
                                        $titleWasConverted = $unconvertedTitle !== $titleObj->getPrefixedText();
                                }
-                               
-                               
+
+
                                if ( $titleObj->getNamespace() < 0 ) {
                                        // Handle Special and Media pages
                                        $titleObj = $titleObj->fixSpecialName();