From: Aaron Schulz Date: Thu, 18 Jul 2013 03:37:38 +0000 (-0700) Subject: Allow for IDatabase to be used as type hints for DatabaseBase|DBConnRef X-Git-Tag: 1.31.0-rc.0~19170 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/fiche.php?a=commitdiff_plain;h=1fbb0404f54d8e8a56378ae9d957a2982b3d7194;p=lhc%2Fweb%2Fwiklou.git Allow for IDatabase to be used as type hints for DatabaseBase|DBConnRef * Use this in LogEntry to avoid needless type errors Change-Id: I8644b35b0d9cd171243dd28de52e94ef39d361a7 --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 2f0ac23c51..0950e5f638 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -486,6 +486,7 @@ $wgAutoloadLocalClasses = array( 'DBConnRef' => 'includes/db/LoadBalancer.php', 'DBError' => 'includes/db/DatabaseError.php', 'DBObject' => 'includes/db/DatabaseUtility.php', + 'IDatabase' => 'includes/db/Database.php', 'IORMRow' => 'includes/db/IORMRow.php', 'IORMTable' => 'includes/db/IORMTable.php', 'DBMasterPos' => 'includes/db/DatabaseUtility.php', diff --git a/includes/db/Database.php b/includes/db/Database.php index a86d6be981..04f1f97f56 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -204,11 +204,17 @@ interface DatabaseType { function getServerInfo(); } +/** + * Interface for classes that implement or wrap DatabaseBase + * @ingroup Database + */ +interface IDatabase {} + /** * Database abstraction object * @ingroup Database */ -abstract class DatabaseBase implements DatabaseType { +abstract class DatabaseBase implements IDatabase, DatabaseType { /** Number of times to re-try an operation in case of deadlock */ const DEADLOCK_TRIES = 4; /** Minimum time to wait before retry, in microseconds */ diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index ab200b4a9a..5c4443da9d 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -1091,7 +1091,7 @@ class LoadBalancer { * @ingroup Database * @since 1.22 */ -class DBConnRef { +class DBConnRef implements IDatabase { /** @var LoadBalancer */ protected $lb; /** @var DatabaseBase */ diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index fee4fab6e0..16b72ea63c 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -442,10 +442,10 @@ class ManualLogEntry extends LogEntryBase { /** * Inserts the entry into the logging table. - * @param DatabaseBase $dbw + * @param IDatabase $dbw * @return int If of the log entry */ - public function insert( DatabaseBase $dbw = null ) { + public function insert( IDatabase $dbw = null ) { global $wgContLang; $dbw = $dbw ?: wfGetDB( DB_MASTER );