X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Fdatabase%2FDatabaseMssql.php;h=9d4a364a88c5d39fe716b37423829a8ea32bd642;hb=dbdbeb7af2a7f0ee00bdc4dfc1297edf0405a8fd;hp=d06bcb9274c67cae3d48be231ed59c214ccf0ccc;hpb=c351a9cab09277b0a0517624ddd2aa1bdb264c4e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/database/DatabaseMssql.php b/includes/libs/rdbms/database/DatabaseMssql.php index d06bcb9274..9d4a364a88 100644 --- a/includes/libs/rdbms/database/DatabaseMssql.php +++ b/includes/libs/rdbms/database/DatabaseMssql.php @@ -59,10 +59,6 @@ class DatabaseMssql extends Database { /** @var string[] */ protected $ignoreErrors = []; - public function implicitGroupby() { - return false; - } - public function implicitOrderby() { return false; } @@ -79,53 +75,50 @@ class DatabaseMssql extends Database { } protected function open( $server, $user, $password, $dbName, $schema, $tablePrefix ) { - // Test for driver support, to avoid suppressed fatal error if ( !function_exists( 'sqlsrv_connect' ) ) { throw new DBConnectionError( $this, - "Microsoft SQL Server Native (sqlsrv) functions missing. - You can download the driver from: http://go.microsoft.com/fwlink/?LinkId=123470\n" + "Microsoft SQL Server Native (sqlsrv) functions missing.\n + You can download the driver from: http://go.microsoft.com/fwlink/?LinkId=123470" ); } $this->close(); + + if ( $schema !== null ) { + throw $this->newExceptionAfterConnectError( "Got schema '$schema'; not supported." ); + } + $this->server = $server; $this->user = $user; $this->password = $password; $connectionInfo = []; - - if ( $dbName != '' ) { + if ( strlen( $dbName ) ) { $connectionInfo['Database'] = $dbName; } - - // Decide which auth scenerio to use - // if we are using Windows auth, then don't add credentials to $connectionInfo if ( !$this->useWindowsAuth ) { $connectionInfo['UID'] = $user; $connectionInfo['PWD'] = $password; } AtEase::suppressWarnings(); - $this->conn = sqlsrv_connect( $server, $connectionInfo ); + $this->conn = sqlsrv_connect( $server, $connectionInfo ) ?: null; AtEase::restoreWarnings(); - if ( $this->conn === false ) { - $error = $this->lastError(); - $this->connLogger->error( - "Error connecting to {db_server}: {error}", - $this->getLogContext( [ 'method' => __METHOD__, 'error' => $error ] ) - ); - throw new DBConnectionError( $this, $error ); + if ( !$this->conn ) { + throw $this->newExceptionAfterConnectError( $this->lastError() ); } - $this->currentDomain = new DatabaseDomain( - ( $dbName != '' ) ? $dbName : null, - null, - $tablePrefix - ); - - return (bool)$this->conn; + try { + $this->currentDomain = new DatabaseDomain( + strlen( $dbName ) ? $dbName : null, + null, + $tablePrefix + ); + } catch ( Exception $e ) { + throw $this->newExceptionAfterConnectError( $e->getMessage() ); + } } /** @@ -792,7 +785,6 @@ class DatabaseMssql extends Database { * * @param array $options An array of UPDATE options, can be: * - IGNORE: Ignore unique key conflicts - * - LOW_PRIORITY: MySQL-specific, see MySQL manual. * @return bool * @throws DBUnexpectedError * @throws Exception