From fb10df98df5cad78312e270f2d59733c5d2a3ce5 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 24 Apr 2015 10:00:22 -0700 Subject: Moved DBConnRef to a separate file Change-Id: I9c8570aefb8927a3d69b7fd446165f6e8661e84d --- includes/db/DBConnRef.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 includes/db/DBConnRef.php (limited to 'includes/db/DBConnRef.php') diff --git a/includes/db/DBConnRef.php b/includes/db/DBConnRef.php new file mode 100644 index 000000000000..7045494abd18 --- /dev/null +++ b/includes/db/DBConnRef.php @@ -0,0 +1,46 @@ +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 ); + } + } +} -- cgit v1.2.3