http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89549

Revision: 89549
Author:   gurch
Date:     2011-06-06 08:45:54 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
follow up r89513: avoid internal error when only invalid revids/pageids are 
passed

Modified Paths:
--------------
    trunk/phase3/includes/api/ApiPageSet.php

Modified: trunk/phase3/includes/api/ApiPageSet.php
===================================================================
--- trunk/phase3/includes/api/ApiPageSet.php    2011-06-06 00:56:05 UTC (rev 
89548)
+++ trunk/phase3/includes/api/ApiPageSet.php    2011-06-06 08:45:54 UTC (rev 
89549)
@@ -451,17 +451,19 @@
 
                $pageids = self::getPositiveIntegers( $pageids );
 
-               $set = array(
-                       'page_id' => $pageids
-               );
-               $db = $this->getDB();
+               if ( count( $pageids ) ) {
+                       $set = array(
+                               'page_id' => $pageids
+                       );
+                       $db = $this->getDB();
 
-               // Get pageIDs data from the `page` table
-               $this->profileDBIn();
-               $res = $db->select( 'page', $this->getPageTableFields(), $set,
-                                       __METHOD__ );
-               $this->profileDBOut();
-
+                       // Get pageIDs data from the `page` table
+                       $this->profileDBIn();
+                       $res = $db->select( 'page', 
$this->getPageTableFields(), $set,
+                                               __METHOD__ );
+                       $this->profileDBOut();
+               }
+               
                $this->initFromQueryResult( $res, $remaining, false );  // 
process PageIDs
 
                // Resolve any found redirects
@@ -540,21 +542,23 @@
 
                $revids = self::getPositiveIntegers( $revids );
 
-               $tables = array( 'revision', 'page' );
-               $fields = array( 'rev_id', 'rev_page' );
-               $where = array( 'rev_id' => $revids, 'rev_page = page_id' );
+               if ( count( $revids ) ) {
+                       $tables = array( 'revision', 'page' );
+                       $fields = array( 'rev_id', 'rev_page' );
+                       $where = array( 'rev_id' => $revids, 'rev_page = 
page_id' );
 
-               // Get pageIDs data from the `page` table
-               $this->profileDBIn();
-               $res = $db->select( $tables, $fields, $where,  __METHOD__ );
-               foreach ( $res as $row ) {
-                       $revid = intval( $row->rev_id );
-                       $pageid = intval( $row->rev_page );
-                       $this->mGoodRevIDs[$revid] = $pageid;
-                       $pageids[$pageid] = '';
-                       unset( $remaining[$revid] );
+                       // Get pageIDs data from the `page` table
+                       $this->profileDBIn();
+                       $res = $db->select( $tables, $fields, $where,  
__METHOD__ );
+                       foreach ( $res as $row ) {
+                               $revid = intval( $row->rev_id );
+                               $pageid = intval( $row->rev_page );
+                               $this->mGoodRevIDs[$revid] = $pageid;
+                               $pageids[$pageid] = '';
+                               unset( $remaining[$revid] );
+                       }
+                       $this->profileDBOut();
                }
-               $this->profileDBOut();
 
                $this->mMissingRevIDs = array_keys( $remaining );
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to