[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Move mssql class to /libs

2017-02-10 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/336932 )

Change subject: Move mssql class to /libs
..


Move mssql class to /libs

* Inject global variables in MWLBFactory.php
* Remove incompatible ignoreErrors() override which is only called
  from the base classes.
* Remove use of wf* methods.

Change-Id: Idf8202474182cc82fb6ef453e2722e7af17e32aa
---
M autoload.php
M includes/db/MWLBFactory.php
R includes/libs/rdbms/database/DatabaseMssql.php
3 files changed, 49 insertions(+), 67 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/autoload.php b/autoload.php
index 1cb8a14..c64e49d 100644
--- a/autoload.php
+++ b/autoload.php
@@ -327,7 +327,7 @@
'DatabaseInstaller' => __DIR__ . 
'/includes/installer/DatabaseInstaller.php',
'DatabaseLag' => __DIR__ . '/maintenance/lag.php',
'DatabaseLogEntry' => __DIR__ . '/includes/logging/LogEntry.php',
-   'DatabaseMssql' => __DIR__ . '/includes/db/DatabaseMssql.php',
+   'DatabaseMssql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMssql.php',
'DatabaseMysql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysql.php',
'DatabaseMysqlBase' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqlBase.php',
'DatabaseMysqli' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqli.php',
diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php
index 09d8fab..0186222 100644
--- a/includes/db/MWLBFactory.php
+++ b/includes/db/MWLBFactory.php
@@ -72,7 +72,13 @@
// Work around the 
reserved word usage in MediaWiki schema
'keywordTableMap' => [ 
'user' => 'mwuser', 'text' => 'pagecontent' ]
];
+   } elseif ( $server['type'] === 'mssql' 
) {
+   $server += [
+   'port' => 
$mainConfig->get( 'DBport' ),
+   'useWindowsAuth' => 
$mainConfig->get( 'DBWindowsAuthentication' )
+   ];
}
+
if ( in_array( $server['type'], 
$typesWithSchema, true ) ) {
$server += [ 'schema' => 
$mainConfig->get( 'DBmwschema' ) ];
}
@@ -112,6 +118,9 @@
$server['port'] = $mainConfig->get( 
'DBport' );
// Work around the reserved word usage 
in MediaWiki schema
$server['keywordTableMap'] = [ 'user' 
=> 'mwuser', 'text' => 'pagecontent' ];
+   } elseif ( $server['type'] === 'mssql' ) {
+   $server['port'] = $mainConfig->get( 
'DBport' );
+   $server['useWindowsAuth'] = 
$mainConfig->get( 'DBWindowsAuthentication' );
}
$lbConf['servers'] = [ $server ];
}
diff --git a/includes/db/DatabaseMssql.php 
b/includes/libs/rdbms/database/DatabaseMssql.php
similarity index 93%
rename from includes/db/DatabaseMssql.php
rename to includes/libs/rdbms/database/DatabaseMssql.php
index d567d8b..b91c7b7 100644
--- a/includes/db/DatabaseMssql.php
+++ b/includes/libs/rdbms/database/DatabaseMssql.php
@@ -29,6 +29,9 @@
  * @ingroup Database
  */
 class DatabaseMssql extends Database {
+   protected $mPort;
+   protected $mUseWindowsAuth = false;
+
protected $mInsertId = null;
protected $mLastResult = null;
protected $mAffectedRows = null;
@@ -40,8 +43,6 @@
protected $mIgnoreDupKeyErrors = false;
protected $mIgnoreErrors = [];
 
-   protected $mPort;
-
public function implicitGroupby() {
return false;
}
@@ -52,6 +53,13 @@
 
public function unionSupportsOrderAndLimit() {
return false;
+   }
+
+   public function __construct( array $params ) {
+   $this->mPort = $params['port'];
+   $this->mUseWindowsAuth = $params['UseWindowsAuth'];
+
+   parent::__construct( $params );
}
 
/**
@@ -73,8 +81,6 @@
);
}
 
-   global $wgDBport, $wgDBWindowsAuthentication;
-
# e.g. the class is being loaded
if ( !strlen( $user ) ) {
return null;
@@ -82,7 +88,6 @@
 
$this->close();
$this->mServer = $server;
-   $this->mPort = $wgDBport;
  

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Move mssql class to /libs

2017-02-09 Thread Aaron Schulz (Code Review)
Aaron Schulz has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/336932 )

Change subject: Move mssql class to /libs
..

Move mssql class to /libs

* Inject global variables in MWLBFactory.php
* Remove incompatible ignoreErrors() override which is only called
  from the base classes.
* Remove use of wf* methods.

Change-Id: Idf8202474182cc82fb6ef453e2722e7af17e32aa
---
M includes/db/MWLBFactory.php
R includes/libs/rdbms/database/DatabaseMssql.php
2 files changed, 46 insertions(+), 65 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/32/336932/1

diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php
index 09d8fab..0186222 100644
--- a/includes/db/MWLBFactory.php
+++ b/includes/db/MWLBFactory.php
@@ -72,7 +72,13 @@
// Work around the 
reserved word usage in MediaWiki schema
'keywordTableMap' => [ 
'user' => 'mwuser', 'text' => 'pagecontent' ]
];
+   } elseif ( $server['type'] === 'mssql' 
) {
+   $server += [
+   'port' => 
$mainConfig->get( 'DBport' ),
+   'useWindowsAuth' => 
$mainConfig->get( 'DBWindowsAuthentication' )
+   ];
}
+
if ( in_array( $server['type'], 
$typesWithSchema, true ) ) {
$server += [ 'schema' => 
$mainConfig->get( 'DBmwschema' ) ];
}
@@ -112,6 +118,9 @@
$server['port'] = $mainConfig->get( 
'DBport' );
// Work around the reserved word usage 
in MediaWiki schema
$server['keywordTableMap'] = [ 'user' 
=> 'mwuser', 'text' => 'pagecontent' ];
+   } elseif ( $server['type'] === 'mssql' ) {
+   $server['port'] = $mainConfig->get( 
'DBport' );
+   $server['useWindowsAuth'] = 
$mainConfig->get( 'DBWindowsAuthentication' );
}
$lbConf['servers'] = [ $server ];
}
diff --git a/includes/db/DatabaseMssql.php 
b/includes/libs/rdbms/database/DatabaseMssql.php
similarity index 93%
rename from includes/db/DatabaseMssql.php
rename to includes/libs/rdbms/database/DatabaseMssql.php
index d567d8b..30ecc8e 100644
--- a/includes/db/DatabaseMssql.php
+++ b/includes/libs/rdbms/database/DatabaseMssql.php
@@ -29,6 +29,9 @@
  * @ingroup Database
  */
 class DatabaseMssql extends Database {
+   protected $mPort;
+   protected $mUseWindowsAuth = false;
+
protected $mInsertId = null;
protected $mLastResult = null;
protected $mAffectedRows = null;
@@ -40,8 +43,6 @@
protected $mIgnoreDupKeyErrors = false;
protected $mIgnoreErrors = [];
 
-   protected $mPort;
-
public function implicitGroupby() {
return false;
}
@@ -52,6 +53,13 @@
 
public function unionSupportsOrderAndLimit() {
return false;
+   }
+
+   public function __construct( array $params ) {
+   $this->mPort = $params['port'];
+   $this->mUseWindowsAuth = $params['UseWindowsAuth'];
+
+   parent::__construct( $params );
}
 
/**
@@ -73,8 +81,6 @@
);
}
 
-   global $wgDBport, $wgDBWindowsAuthentication;
-
# e.g. the class is being loaded
if ( !strlen( $user ) ) {
return null;
@@ -82,7 +88,6 @@
 
$this->close();
$this->mServer = $server;
-   $this->mPort = $wgDBport;
$this->mUser = $user;
$this->mPassword = $password;
$this->mDBname = $dbName;
@@ -95,7 +100,7 @@
 
// Decide which auth scenerio to use
// if we are using Windows auth, then don't add credentials to 
$connectionInfo
-   if ( !$wgDBWindowsAuthentication ) {
+   if ( !$this->mUseWindowsAuth ) {
$connectionInfo['UID'] = $user;
$connectionInfo['PWD'] = $password;
}
@@ -141,15 +146,10 @@
 
/**
 * @param string $sql
-* @return bool|MssqlResult
+* @return bool|MssqlResultWrapper|resource
 * @throws DBUnexpectedError
 */
protected function doQuery( $sql ) {
-   if (