Merge "Pass the result of the database queries in Title::getPreviousRevisionID()...
authorSiebrand <s.mazeland@xs4all.nl>
Mon, 7 May 2012 10:22:46 +0000 (10:22 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 7 May 2012 10:22:46 +0000 (10:22 +0000)
1  2 
includes/Title.php

diff --combined includes/Title.php
@@@ -181,12 -181,13 +181,12 @@@ class Title 
         * @return Title the new object, or NULL on an error
         */
        public static function newFromURL( $url ) {
 -              global $wgLegalTitleChars;
                $t = new Title();
  
                # For compatibility with old buggy URLs. "+" is usually not valid in titles,
                # but some URLs used it as a space replacement and they still come
                # from some external search tools.
 -              if ( strpos( $wgLegalTitleChars, '+' ) === false ) {
 +              if ( strpos( self::legalChars(), '+' ) === false ) {
                        $url = str_replace( '+', ' ', $url );
                }
  
         */
        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 )
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_id DESC' )
                );
+               if ( $revId === false ) {
+                       return false;
+               } else {
+                       return intval( $revId );
+               }
        }
  
        /**
         */
        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 )
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_id' )
                );
+               if ( $revId === false ) {
+                       return false;
+               } else {
+                       return intval( $revId );
+               }
        }
  
        /**
                $dbr = wfGetDB( DB_SLAVE );
                $this->mNotificationTimestamp[$uid] = $dbr->selectField( 'watchlist',
                        'wl_notificationtimestamp',
 -                      array( 'wl_namespace' => $this->getNamespace(),
 +                      array(
 +                              'wl_user' => $user->getId(),
 +                              'wl_namespace' => $this->getNamespace(),
                                'wl_title' => $this->getDBkey(),
 -                              'wl_user' => $user->getId()
                        ),
                        __METHOD__
                );