Pass the result of the database queries in Title::getPreviousRevisionID() and Title...
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Wed, 2 May 2012 08:27:21 +0000 (10:27 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Wed, 2 May 2012 08:52:51 +0000 (10:52 +0200)
No idea why mysql_fetch_object() returns string when the field in defined as integer, but it is so on my machine...

Change-Id: I353c6087d20d7a72d6d4b39bdc477b094bc460f6

includes/Title.php

index d26f71c..2748651 100644 (file)
@@ -3919,7 +3919,7 @@ class Title {
         */
        public function getPreviousRevisionID( $revId, $flags = 0 ) {
                $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
-               return $db->selectField( 'revision', 'rev_id',
+               $revId = $db->selectField( 'revision', 'rev_id',
                        array(
                                'rev_page' => $this->getArticleID( $flags ),
                                'rev_id < ' . intval( $revId )
@@ -3927,6 +3927,12 @@ class Title {
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_id DESC' )
                );
+
+               if ( $revId === false ) {
+                       return false;
+               } else {
+                       return intval( $revId );
+               }
        }
 
        /**
@@ -3938,7 +3944,7 @@ class Title {
         */
        public function getNextRevisionID( $revId, $flags = 0 ) {
                $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
-               return $db->selectField( 'revision', 'rev_id',
+               $revId = $db->selectField( 'revision', 'rev_id',
                        array(
                                'rev_page' => $this->getArticleID( $flags ),
                                'rev_id > ' . intval( $revId )
@@ -3946,6 +3952,12 @@ class Title {
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_id' )
                );
+
+               if ( $revId === false ) {
+                       return false;
+               } else {
+                       return intval( $revId );
+               }
        }
 
        /**