From: Kevin Israel Date: Fri, 12 Sep 2014 04:12:38 +0000 (-0400) Subject: Remove redundant $db->resultObject() calls X-Git-Tag: 1.31.0-rc.0~13924 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=3daf61814db326f81c612186754f545c0548501e;p=lhc%2Fweb%2Fwiklou.git Remove redundant $db->resultObject() calls DatabaseBase::query() already passes the value returned by the database driver (usually an object or resource for SELECT queries) through $db->resultObject(). There is no need to pass it through the method a second time to get a ResultWrapper. Change-Id: I5d34ab2bffb7f236d2f824b4ef0e8670f89d4599 --- diff --git a/includes/Export.php b/includes/Export.php index 48a814d322..84f5c60cec 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -267,7 +267,7 @@ class WikiExporter { if ( $this->buffer == WikiExporter::STREAM ) { $prev = $this->db->bufferResults( false ); } - $wrapper = null; // Assuring $wrapper is not undefined, if exception occurs early + $result = null; // Assuring $result is not undefined, if exception occurs early try { $result = $this->db->select( array( 'logging', 'user' ), array( "{$logging}.*", 'user_name' ), // grab the user name @@ -275,8 +275,7 @@ class WikiExporter { __METHOD__, array( 'ORDER BY' => 'log_id', 'USE INDEX' => array( 'logging' => 'PRIMARY' ) ) ); - $wrapper = $this->db->resultObject( $result ); - $this->outputLogStream( $wrapper ); + $this->outputLogStream( $result ); if ( $this->buffer == WikiExporter::STREAM ) { $this->db->bufferResults( $prev ); } @@ -286,8 +285,8 @@ class WikiExporter { // Freeing result try { - if ( $wrapper ) { - $wrapper->free(); + if ( $result ) { + $result->free(); } } catch ( Exception $e2 ) { // Already in panic mode -> ignoring $e2 as $e has @@ -377,16 +376,15 @@ class WikiExporter { $prev = $this->db->bufferResults( false ); } - $wrapper = null; // Assuring $wrapper is not undefined, if exception occurs early + $result = null; // Assuring $result is not undefined, if exception occurs early try { wfRunHooks( 'ModifyExportQuery', array( $this->db, &$tables, &$cond, &$opts, &$join ) ); # Do the query! $result = $this->db->select( $tables, '*', $cond, __METHOD__, $opts, $join ); - $wrapper = $this->db->resultObject( $result ); # Output dump results - $this->outputPageStream( $wrapper ); + $this->outputPageStream( $result ); if ( $this->buffer == WikiExporter::STREAM ) { $this->db->bufferResults( $prev ); @@ -397,8 +395,8 @@ class WikiExporter { // Freeing result try { - if ( $wrapper ) { - $wrapper->free(); + if ( $result ) { + $result->free(); } } catch ( Exception $e2 ) { // Already in panic mode -> ignoring $e2 as $e has @@ -467,7 +465,7 @@ class WikiExporter { } /** - * @param array $resultset + * @param ResultWrapper $resultset */ protected function outputLogStream( $resultset ) { foreach ( $resultset as $row ) { diff --git a/includes/search/SearchMssql.php b/includes/search/SearchMssql.php index de701f7355..0d7970de38 100644 --- a/includes/search/SearchMssql.php +++ b/includes/search/SearchMssql.php @@ -34,10 +34,7 @@ class SearchMssql extends SearchDatabase { * @access public */ function searchText( $term ) { - $resultSet = $this->db->resultObject( - $this->db->query( $this->getQuery( $this->filter( $term ), true ) ) - ); - + $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), true ) ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } @@ -49,10 +46,7 @@ class SearchMssql extends SearchDatabase { * @access public */ function searchTitle( $term ) { - $resultSet = $this->db->resultObject( - $this->db->query( $this->getQuery( $this->filter( $term ), false ) ) - ); - + $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), false ) ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 348da79a9f..58211484ab 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -69,10 +69,7 @@ class SearchOracle extends SearchDatabase { return new SqlSearchResultSet( false, '' ); } - $resultSet = $this->db->resultObject( - $this->db->query( $this->getQuery( $this->filter( $term ), true ) ) - ); - + $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), true ) ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } @@ -87,10 +84,7 @@ class SearchOracle extends SearchDatabase { return new SqlSearchResultSet( false, '' ); } - $resultSet = $this->db->resultObject( - $this->db->query( $this->getQuery( $this->filter( $term ), false ) ) - ); - + $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), false ) ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index c64c845650..59b0c31c9c 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -40,7 +40,7 @@ class SearchPostgres extends SearchDatabase { function searchTitle( $term ) { $q = $this->searchQuery( $term, 'titlevector', 'page_title' ); $olderror = error_reporting( E_ERROR ); - $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) ); + $resultSet = $this->db->query( $q, 'SearchPostgres', true ); error_reporting( $olderror ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } @@ -48,7 +48,7 @@ class SearchPostgres extends SearchDatabase { function searchText( $term ) { $q = $this->searchQuery( $term, 'textvector', 'old_text' ); $olderror = error_reporting( E_ERROR ); - $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) ); + $resultSet = $this->db->query( $q, 'SearchPostgres', true ); error_reporting( $olderror ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index 89439961e0..b229e06e61 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -406,7 +406,7 @@ abstract class QueryPage extends SpecialPage { $res = $dbr->query( $sql, $fname ); } - return $dbr->resultObject( $res ); + return $res; } /** diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index cfadddb292..c3e871b840 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -99,7 +99,7 @@ class PageArchive { * @return bool|ResultWrapper */ protected static function listPages( $dbr, $condition ) { - return $dbr->resultObject( $dbr->select( + return $dbr->select( array( 'archive' ), array( 'ar_namespace', @@ -113,7 +113,7 @@ class PageArchive { 'ORDER BY' => array( 'ar_namespace', 'ar_title' ), 'LIMIT' => 100, ) - ) ); + ); } /** @@ -152,15 +152,13 @@ class PageArchive { $options ); - $res = $dbr->select( $tables, + return $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds ); - - return $dbr->resultObject( $res ); } /** @@ -177,15 +175,13 @@ class PageArchive { } $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( + return $dbr->select( 'filearchive', ArchivedFile::selectFields(), array( 'fa_name' => $this->title->getDBkey() ), __METHOD__, array( 'ORDER BY' => 'fa_timestamp DESC' ) ); - - return $dbr->resultObject( $res ); } /** @@ -532,9 +528,8 @@ class PageArchive { __METHOD__, /* options */ array( 'ORDER BY' => 'ar_timestamp' ) ); - $ret = $dbw->resultObject( $result ); - $rev_count = $dbw->numRows( $result ); + $rev_count = $result->numRows(); if ( !$rev_count ) { wfDebug( __METHOD__ . ": no revisions to restore\n" ); @@ -544,10 +539,10 @@ class PageArchive { return $status; } - $ret->seek( $rev_count - 1 ); // move to last - $row = $ret->fetchObject(); // get newest archived rev + $result->seek( $rev_count - 1 ); // move to last + $row = $result->fetchObject(); // get newest archived rev $oldPageId = (int)$row->ar_page_id; // pass this to ArticleUndelete hook - $ret->seek( 0 ); // move back + $result->seek( 0 ); // move back // grab the content to check consistency with global state before restoring the page. $revision = Revision::newFromArchiveRow( $row, @@ -589,7 +584,7 @@ class PageArchive { $revision = null; $restored = 0; - foreach ( $ret as $row ) { + foreach ( $result as $row ) { // Check for key dupes due to shitty archive integrity. if ( $row->ar_rev_id ) { $exists = $dbw->selectField( 'revision', '1',