X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Fdatabase%2FDatabaseMssql.php;h=c7e12894e0309f6ec70d63b459b50e04822c5a2f;hb=b4e9b1ba621d77b580cfd5b19e927ccaec54831a;hp=4ebc6233ed49e360b553365e6cfb39b5df7b2d23;hpb=426719108b86bba70e5b321e3386f40849471426;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/database/DatabaseMssql.php b/includes/libs/rdbms/database/DatabaseMssql.php index 4ebc6233ed..c7e12894e0 100644 --- a/includes/libs/rdbms/database/DatabaseMssql.php +++ b/includes/libs/rdbms/database/DatabaseMssql.php @@ -27,7 +27,7 @@ namespace Wikimedia\Rdbms; -use MediaWiki; +use Wikimedia; use Exception; use stdClass; @@ -93,10 +93,10 @@ class DatabaseMssql extends Database { } $this->close(); - $this->mServer = $server; - $this->mUser = $user; - $this->mPassword = $password; - $this->mDBname = $dbName; + $this->server = $server; + $this->user = $user; + $this->password = $password; + $this->dbName = $dbName; $connectionInfo = []; @@ -111,17 +111,17 @@ class DatabaseMssql extends Database { $connectionInfo['PWD'] = $password; } - MediaWiki\suppressWarnings(); - $this->mConn = sqlsrv_connect( $server, $connectionInfo ); - MediaWiki\restoreWarnings(); + Wikimedia\suppressWarnings(); + $this->conn = sqlsrv_connect( $server, $connectionInfo ); + Wikimedia\restoreWarnings(); - if ( $this->mConn === false ) { + if ( $this->conn === false ) { throw new DBConnectionError( $this, $this->lastError() ); } - $this->mOpened = true; + $this->opened = true; - return $this->mConn; + return $this->conn; } /** @@ -130,7 +130,7 @@ class DatabaseMssql extends Database { * @return bool */ protected function closeConnection() { - return sqlsrv_close( $this->mConn ); + return sqlsrv_close( $this->conn ); } /** @@ -186,10 +186,10 @@ class DatabaseMssql extends Database { if ( $this->mPrepareStatements ) { // we do prepare + execute so we can get its field metadata for later usage if desired - $stmt = sqlsrv_prepare( $this->mConn, $sql, [], $scrollArr ); + $stmt = sqlsrv_prepare( $this->conn, $sql, [], $scrollArr ); $success = sqlsrv_execute( $stmt ); } else { - $stmt = sqlsrv_query( $this->mConn, $sql, [], $scrollArr ); + $stmt = sqlsrv_query( $this->conn, $sql, [], $scrollArr ); $success = (bool)$stmt; } @@ -353,7 +353,7 @@ class DatabaseMssql extends Database { /** * @return int */ - public function affectedRows() { + protected function fetchAffectedRowCount() { return $this->mAffectedRows; } @@ -440,8 +440,14 @@ class DatabaseMssql extends Database { if ( strpos( $sql, 'MAX(' ) !== false || strpos( $sql, 'MIN(' ) !== false ) { $bitColumns = []; if ( is_array( $table ) ) { - foreach ( $table as $t ) { - $bitColumns += $this->getBitColumns( $this->tableName( $t ) ); + $tables = $table; + while ( $tables ) { + $t = array_pop( $tables ); + if ( is_array( $t ) ) { + $tables = array_merge( $tables, $t ); + } else { + $bitColumns += $this->getBitColumns( $this->tableName( $t ) ); + } } } else { $bitColumns = $this->getBitColumns( $this->tableName( $table ) ); @@ -947,7 +953,7 @@ class DatabaseMssql extends Database { * @return string Version information from the database */ public function getServerVersion() { - $server_info = sqlsrv_server_info( $this->mConn ); + $server_info = sqlsrv_server_info( $this->conn ); $version = 'Error'; if ( isset( $server_info['SQLServerVersion'] ) ) { $version = $server_info['SQLServerVersion']; @@ -971,7 +977,7 @@ class DatabaseMssql extends Database { } if ( $schema === false ) { - $schema = $this->mSchema; + $schema = $this->schema; } $res = $this->query( "SELECT 1 FROM INFORMATION_SCHEMA.TABLES @@ -1036,8 +1042,8 @@ class DatabaseMssql extends Database { * @param string $fname */ protected function doBegin( $fname = __METHOD__ ) { - sqlsrv_begin_transaction( $this->mConn ); - $this->mTrxLevel = 1; + sqlsrv_begin_transaction( $this->conn ); + $this->trxLevel = 1; } /** @@ -1045,8 +1051,8 @@ class DatabaseMssql extends Database { * @param string $fname */ protected function doCommit( $fname = __METHOD__ ) { - sqlsrv_commit( $this->mConn ); - $this->mTrxLevel = 0; + sqlsrv_commit( $this->conn ); + $this->trxLevel = 0; } /** @@ -1055,8 +1061,8 @@ class DatabaseMssql extends Database { * @param string $fname */ protected function doRollback( $fname = __METHOD__ ) { - sqlsrv_rollback( $this->mConn ); - $this->mTrxLevel = 0; + sqlsrv_rollback( $this->conn ); + $this->trxLevel = 0; } /** @@ -1065,7 +1071,6 @@ class DatabaseMssql extends Database { */ public function strencode( $s ) { // Should not be called by us - return str_replace( "'", "''", $s ); } @@ -1126,7 +1131,7 @@ class DatabaseMssql extends Database { */ public function selectDB( $db ) { try { - $this->mDBname = $db; + $this->dbName = $db; $this->query( "USE $db" ); return true; } catch ( Exception $e ) { @@ -1250,8 +1255,8 @@ class DatabaseMssql extends Database { private function populateColumnCaches() { $res = $this->select( 'INFORMATION_SCHEMA.COLUMNS', '*', [ - 'TABLE_CATALOG' => $this->mDBname, - 'TABLE_SCHEMA' => $this->mSchema, + 'TABLE_CATALOG' => $this->dbName, + 'TABLE_SCHEMA' => $this->schema, 'DATA_TYPE' => [ 'varbinary', 'binary', 'image', 'bit' ] ] );