diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2016-09-02 06:46:56 -0700 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2016-09-02 21:48:10 +0000 |
commit | 5f102cbd7c038727294e6aedf9b443cd77cb1434 (patch) | |
tree | c92aeaf64a797e8b98f04e5ba790cdecbe65b658 /includes/Revision.php | |
parent | f7d75435afe6589ee4b05f02259def121d633954 (diff) | |
download | mediawikicore-5f102cbd7c038727294e6aedf9b443cd77cb1434.tar.gz mediawikicore-5f102cbd7c038727294e6aedf9b443cd77cb1434.zip |
Convert Revision::fetchFromConds() to using more modern selectRow()
Change-Id: Icb3fa46beb7f49a43ffa40eb8f505a3717cd730b
Diffstat (limited to 'includes/Revision.php')
-rw-r--r-- | includes/Revision.php | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/includes/Revision.php b/includes/Revision.php index eda898916c72..25806686215a 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -340,16 +340,9 @@ class Revision implements IDBAccessObject { * @return Revision|null */ private static function loadFromConds( $db, $conditions, $flags = 0 ) { - $res = self::fetchFromConds( $db, $conditions, $flags ); - if ( $res ) { - $row = $res->fetchObject(); - if ( $row ) { - $ret = new Revision( $row ); - return $ret; - } - } - $ret = null; - return $ret; + $row = self::fetchFromConds( $db, $conditions, $flags ); + + return $row ? new Revision( $row ) : null; } /** @@ -357,11 +350,12 @@ class Revision implements IDBAccessObject { * fetch all of a given page's revisions in turn. * Each row can be fed to the constructor to get objects. * - * @param Title $title + * @param LinkTarget $title * @return ResultWrapper + * @deprecated Since 1.28 */ - public static function fetchRevision( $title ) { - return self::fetchFromConds( + public static function fetchRevision( LinkTarget $title ) { + $row = self::fetchFromConds( wfGetDB( DB_SLAVE ), [ 'rev_id=page_latest', @@ -369,6 +363,8 @@ class Revision implements IDBAccessObject { 'page_title' => $title->getDBkey() ] ); + + return new FakeResultWrapper( $row ? [ $row ] : [] ); } /** @@ -379,7 +375,7 @@ class Revision implements IDBAccessObject { * @param IDatabase $db * @param array $conditions * @param int $flags (optional) - * @return ResultWrapper + * @return stdClass */ private static function fetchFromConds( $db, $conditions, $flags = 0 ) { $fields = array_merge( @@ -387,11 +383,11 @@ class Revision implements IDBAccessObject { self::selectPageFields(), self::selectUserFields() ); - $options = [ 'LIMIT' => 1 ]; + $options = []; if ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING ) { $options[] = 'FOR UPDATE'; } - return $db->select( + return $db->selectRow( [ 'revision', 'page', 'user' ], $fields, $conditions, |