Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/74320


Change subject: Allow for IDatabase to be used as type hints for 
DatabaseBase|DBConnRef
......................................................................

Allow for IDatabase to be used as type hints for DatabaseBase|DBConnRef

* Use this in LogEntry to avoid needless type errors

Change-Id: I8644b35b0d9cd171243dd28de52e94ef39d361a7
---
M includes/AutoLoader.php
M includes/db/Database.php
M includes/db/LoadBalancer.php
M includes/logging/LogEntry.php
4 files changed, 11 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/20/74320/1

diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php
index 2f0ac23..0950e5f 100644
--- a/includes/AutoLoader.php
+++ b/includes/AutoLoader.php
@@ -486,6 +486,7 @@
        '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 a86d6be..04f1f97 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -205,10 +205,16 @@
 }
 
 /**
+ * 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 ab200b4..5c4443d 100644
--- a/includes/db/LoadBalancer.php
+++ b/includes/db/LoadBalancer.php
@@ -1091,7 +1091,7 @@
  * @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 fee4fab..16b72ea 100644
--- a/includes/logging/LogEntry.php
+++ b/includes/logging/LogEntry.php
@@ -442,10 +442,10 @@
 
        /**
         * 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 );

-- 
To view, visit https://gerrit.wikimedia.org/r/74320
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8644b35b0d9cd171243dd28de52e94ef39d361a7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to