Removed all instances of empty() where error suppression was not intended. Replaced...
[lhc/web/wiklou.git] / includes / api / ApiPageSet.php
index 3a1f4fa..908ca22 100644 (file)
@@ -38,7 +38,7 @@ if (!defined('MEDIAWIKI')) {
  * second instance of this class, and all subsequent actions will go use the second instance
  * for all their work.
  *
- * @addtogroup API
+ * @ingroup API
  */
 class ApiPageSet extends ApiQueryBase {
 
@@ -53,7 +53,7 @@ class ApiPageSet extends ApiQueryBase {
        private $mRequestedPageFields;
 
        public function __construct($query, $resolveRedirects = false) {
-               parent :: __construct($query, __CLASS__);
+               parent :: __construct($query, 'query');
 
                $this->mAllPages = array ();
                $this->mTitles = array();
@@ -254,7 +254,9 @@ class ApiPageSet extends ApiQueryBase {
                                break;
                        case 'revids' :
                                if($this->mResolveRedirects)
-                                       $this->dieUsage('revids may not be used with redirect resolution', 'params');
+                                       $this->setWarning('Redirect resolution cannot be used together with the revids= parameter. '.
+                                       'Any redirects the revids= point to have not been resolved.');
+                               $this->mResolveRedirects = false;
                                $this->initFromRevIDs($revids);
                                break;
                        default :
@@ -366,7 +368,7 @@ class ApiPageSet extends ApiQueryBase {
        }
 
        private function initFromPageIds($pageids) {
-               if(empty($pageids))
+               if(!count($pageids))
                        return;
 
                $pageids = array_map('intval', $pageids); // paranoia
@@ -381,7 +383,8 @@ class ApiPageSet extends ApiQueryBase {
                $res = $db->select('page', $this->getPageTableFields(), $set, __METHOD__);
                $this->profileDBOut();
 
-               $this->initFromQueryResult($db, $res, array_flip($pageids), false);     // process PageIDs
+               $remaining = array_flip($pageids);
+               $this->initFromQueryResult($db, $res, $remaining, false);       // process PageIDs
 
                // Resolve any found redirects
                $this->resolvePendingRedirects();
@@ -437,7 +440,7 @@ class ApiPageSet extends ApiQueryBase {
                        else
                        {
                                // The remaining pageids do not exist
-                               if(empty($this->mMissingPageIDs))
+                               if(!$this->mMissingPageIDs)
                                        $this->mMissingPageIDs = array_keys($remaining);
                                else
                                        $this->mMissingPageIDs = array_merge($this->mMissingPageIDs, array_keys($remaining));
@@ -447,7 +450,7 @@ class ApiPageSet extends ApiQueryBase {
 
        private function initFromRevIDs($revids) {
 
-               if(empty($revids))
+               if(!count($revids))
                        return;
 
                $db = $this->getDB();
@@ -474,8 +477,6 @@ class ApiPageSet extends ApiQueryBase {
                $this->mMissingRevIDs = array_keys($remaining);
 
                // Populate all the page information
-               if($this->mResolveRedirects)
-                       ApiBase :: dieDebug(__METHOD__, 'revids may not be used with redirect resolution');
                $this->initFromPageIds(array_keys($pageids));
        }
 
@@ -487,7 +488,7 @@ class ApiPageSet extends ApiQueryBase {
 
                        // Repeat until all redirects have been resolved
                        // The infinite loop is prevented by keeping all known pages in $this->mAllPages
-                       while (!empty ($this->mPendingRedirectIDs)) {
+                       while ($this->mPendingRedirectIDs) {
 
                                // Resolve redirects by querying the pagelinks table, and repeat the process
                                // Create a new linkBatch object for the next pass
@@ -536,7 +537,7 @@ class ApiPageSet extends ApiQueryBase {
                        $this->mRedirectTitles[$from] = $to;
                }
                $db->freeResult($res);
-               if(!empty($this->mPendingRedirectIDs))
+               if($this->mPendingRedirectIDs)
                {
                        # We found pages that aren't in the redirect table
                        # Add them
@@ -551,7 +552,6 @@ class ApiPageSet extends ApiQueryBase {
                                $this->mRedirectTitles[$title->getPrefixedText()] = $rt->getPrefixedText();
                                unset($this->mPendingRedirectIDs[$id]);
                        }
-                       $this->getMain()->scheduleCommit();
                }
                return $lb;
        }
@@ -580,7 +580,7 @@ class ApiPageSet extends ApiQueryBase {
                                continue; // There's nothing else we can do
                        }
                        $iw = $titleObj->getInterwiki();
-                       if (!empty($iw)) {
+                       if (strval($iw) !== '') {
                                // This title is an interwiki link.
                                $this->mInterwikiTitles[$titleObj->getPrefixedText()] = $iw;
                        } else {