public function closeAll() {
$this->forEachOpenConnection( function ( IDatabase $conn ) {
+ $host = $conn->getServer();
+ $this->connLogger->debug( "Closing connection to database '$host'." );
$conn->close();
} );
foreach ( $connsByServer[$serverIndex] as $i => $trackedConn ) {
if ( $conn === $trackedConn ) {
+ $host = $this->getServerName( $i );
+ $this->connLogger->debug( "Closing connection to database $i at '$host'." );
unset( $this->mConns[$type][$serverIndex][$i] );
--$this->connsOpened;
break 2;
$db->tablePrefix( $prefix );
} );
}
+
+ function __destruct() {
+ // Avoid connection leaks for sanity
+ $this->closeAll();
+ }
}