Moved DBConnRef to a separate file
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 24 Apr 2015 17:00:22 +0000 (10:00 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 24 Apr 2015 18:02:50 +0000 (18:02 +0000)
Change-Id: I9c8570aefb8927a3d69b7fd446165f6e8661e84d

autoload.php
includes/db/DBConnRef.php [new file with mode: 0644]
includes/db/LoadBalancer.php

index 754b1bb..71bc7b2 100644 (file)
@@ -278,7 +278,7 @@ $wgAutoloadLocalClasses = array(
        'CurlHttpRequest' => __DIR__ . '/includes/HttpFunctions.php',
        'DBAccessBase' => __DIR__ . '/includes/dao/DBAccessBase.php',
        'DBAccessError' => __DIR__ . '/includes/db/LBFactory.php',
-       'DBConnRef' => __DIR__ . '/includes/db/LoadBalancer.php',
+       'DBConnRef' => __DIR__ . '/includes/db/DBConnRef.php',
        'DBConnectionError' => __DIR__ . '/includes/db/DatabaseError.php',
        'DBError' => __DIR__ . '/includes/db/DatabaseError.php',
        'DBExpectedError' => __DIR__ . '/includes/db/DatabaseError.php',
diff --git a/includes/db/DBConnRef.php b/includes/db/DBConnRef.php
new file mode 100644 (file)
index 0000000..7045494
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Helper class to handle automatically marking connections as reusable (via RAII pattern)
+ * as well handling deferring the actual network connection until the handle is used
+ *
+ * @ingroup Database
+ * @since 1.22
+ */
+class DBConnRef implements IDatabase {
+       /** @var LoadBalancer */
+       private $lb;
+
+       /** @var DatabaseBase|null */
+       private $conn;
+
+       /** @var array|null */
+       private $params;
+
+       /**
+        * @param LoadBalancer $lb
+        * @param DatabaseBase|array $conn Connection or (server index, group, wiki ID) array
+        */
+       public function __construct( LoadBalancer $lb, $conn ) {
+               $this->lb = $lb;
+               if ( $conn instanceof DatabaseBase ) {
+                       $this->conn = $conn;
+               } else {
+                       $this->params = $conn;
+               }
+       }
+
+       public function __call( $name, $arguments ) {
+               if ( $this->conn === null ) {
+                       list( $db, $groups, $wiki ) = $this->params;
+                       $this->conn = $this->lb->getConnection( $db, $groups, $wiki );
+               }
+
+               return call_user_func_array( array( $this->conn, $name ), $arguments );
+       }
+
+       public function __destruct() {
+               if ( $this->conn !== null ) {
+                       $this->lb->reuseConnection( $this->conn );
+               }
+       }
+}
index 624f46b..e1ecf84 100644 (file)
@@ -1272,49 +1272,3 @@ class LoadBalancer {
                $this->mProcCache->clear( 'slave_lag' );
        }
 }
-
-/**
- * Helper class to handle automatically marking connections as reusable (via RAII pattern)
- * as well handling deferring the actual network connection until the handle is used
- *
- * @ingroup Database
- * @since 1.22
- */
-class DBConnRef implements IDatabase {
-       /** @var LoadBalancer */
-       private $lb;
-
-       /** @var DatabaseBase|null */
-       private $conn;
-
-       /** @var array|null */
-       private $params;
-
-       /**
-        * @param LoadBalancer $lb
-        * @param DatabaseBase|array $conn Connection or (server index, group, wiki ID) array
-        */
-       public function __construct( LoadBalancer $lb, $conn ) {
-               $this->lb = $lb;
-               if ( $conn instanceof DatabaseBase ) {
-                       $this->conn = $conn;
-               } else {
-                       $this->params = $conn;
-               }
-       }
-
-       public function __call( $name, $arguments ) {
-               if ( $this->conn === null ) {
-                       list( $db, $groups, $wiki ) = $this->params;
-                       $this->conn = $this->lb->getConnection( $db, $groups, $wiki );
-               }
-
-               return call_user_func_array( array( $this->conn, $name ), $arguments );
-       }
-
-       public function __destruct() {
-               if ( $this->conn !== null ) {
-                       $this->lb->reuseConnection( $this->conn );
-               }
-       }
-}