From 617d59fcb326bd81e244f52c54bf4a83b8dbe0b2 Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Sat, 26 Sep 2015 06:31:05 -0400 Subject: [PATCH] Database: Remove resultObject() from the public interface It has not been necessary to call this method outside the Database classes since 1.11 (r23756 / 9382bc7a858c). This is a breaking change and should not be merged before the following changes to extensions: * Disambiguator: Ibef942fd * Maps: Ic90bd0ad * OAI: Idbbe08d6 * Oversight: I63071e65 * Video: Id71914cd Change-Id: Idfe7cd6f516f0aca850878282c47e7914accc6d8 --- RELEASE-NOTES-1.26 | 2 ++ includes/db/DBConnRef.php | 4 ---- includes/db/Database.php | 9 ++++----- includes/db/DatabaseMssql.php | 4 ++-- includes/db/IDatabase.php | 16 ---------------- 5 files changed, 8 insertions(+), 27 deletions(-) diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index aab1b4254c..7f738e17b0 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -220,6 +220,8 @@ changes to languages because of Phabricator reports. 'Project:Oversight' to 'Project:Suppress'. * (T84937) Free external links ("autolinked" urls) will now be terminated by   and HTML entity encodings of  , <, and >. +* DatabaseBase::resultObject() is now protected (use outside Database classes + not necessary since 1.11). == Compatibility == diff --git a/includes/db/DBConnRef.php b/includes/db/DBConnRef.php index b4f3f79229..ffada49e01 100644 --- a/includes/db/DBConnRef.php +++ b/includes/db/DBConnRef.php @@ -449,10 +449,6 @@ class DBConnRef implements IDatabase { return $this->__call( __FUNCTION__, func_get_args() ); } - public function resultObject( $result ) { - return $this->__call( __FUNCTION__, func_get_args() ); - } - public function ping() { return $this->__call( __FUNCTION__, func_get_args() ); } diff --git a/includes/db/Database.php b/includes/db/Database.php index 1e54f55457..dbe86dcc46 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -3766,14 +3766,13 @@ abstract class DatabaseBase implements IDatabase { * Once upon a time, DatabaseBase::query() returned a bare MySQL result * resource, and it was necessary to call this function to convert it to * a wrapper. Nowadays, raw database objects are never exposed to external - * callers, so this is unnecessary in external code. For compatibility with - * old code, ResultWrapper objects are passed through unaltered. + * callers, so this is unnecessary in external code. * - * @param bool|ResultWrapper|resource $result + * @param bool|ResultWrapper|resource|object $result * @return bool|ResultWrapper */ - public function resultObject( $result ) { - if ( empty( $result ) ) { + protected function resultObject( $result ) { + if ( !$result ) { return false; } elseif ( $result instanceof ResultWrapper ) { return $result; diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index 85f1b96d99..354afc5ae8 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -145,8 +145,8 @@ class DatabaseMssql extends DatabaseBase { * @param bool|MssqlResultWrapper|resource $result * @return bool|MssqlResultWrapper */ - public function resultObject( $result ) { - if ( empty( $result ) ) { + protected function resultObject( $result ) { + if ( !$result ) { return false; } elseif ( $result instanceof MssqlResultWrapper ) { return $result; diff --git a/includes/db/IDatabase.php b/includes/db/IDatabase.php index 49d0514da2..95608c6464 100644 --- a/includes/db/IDatabase.php +++ b/includes/db/IDatabase.php @@ -1347,22 +1347,6 @@ interface IDatabase { */ public function timestampOrNull( $ts = null ); - /** - * Take the result from a query, and wrap it in a ResultWrapper if - * necessary. Boolean values are passed through as is, to indicate success - * of write queries or failure. - * - * Once upon a time, DatabaseBase::query() returned a bare MySQL result - * resource, and it was necessary to call this function to convert it to - * a wrapper. Nowadays, raw database objects are never exposed to external - * callers, so this is unnecessary in external code. For compatibility with - * old code, ResultWrapper objects are passed through unaltered. - * - * @param bool|ResultWrapper|resource $result - * @return bool|ResultWrapper - */ - public function resultObject( $result ); - /** * Ping the server and try to reconnect if it there is no connection * -- 2.20.1