*/
class MssqlInstaller extends DatabaseInstaller {
- protected $globalNames = array(
+ protected $globalNames = [
'wgDBserver',
'wgDBname',
'wgDBuser',
'wgDBmwschema',
'wgDBprefix',
'wgDBWindowsAuthentication',
- );
+ ];
- protected $internalDefaults = array(
+ protected $internalDefaults = [
'_InstallUser' => 'sa',
'_InstallWindowsAuthentication' => 'sqlauth',
'_WebWindowsAuthentication' => 'sqlauth',
- );
+ ];
// SQL Server 2005 RTM
// @todo Are SQL Express version numbers different?)
// These are schema-level privs
// Note: the web user will be created will full permissions if possible, this permission
// list is only used if we are unable to grant full permissions.
- public $webUserPrivs = array(
+ public $webUserPrivs = [
'DELETE',
'INSERT',
'SELECT',
'UPDATE',
'EXECUTE',
- );
+ ];
/**
* @return string
return $this->getTextBox(
'wgDBserver',
'config-db-host',
- array(),
+ [],
$this->parent->getHelpBox( 'config-db-host-help' )
) .
Html::openElement( 'fieldset' ) .
- Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) .
- $this->getTextBox( 'wgDBname', 'config-db-name', array( 'dir' => 'ltr' ),
+ Html::element( 'legend', [], wfMessage( 'config-db-wiki-settings' )->text() ) .
+ $this->getTextBox( 'wgDBname', 'config-db-name', [ 'dir' => 'ltr' ],
$this->parent->getHelpBox( 'config-db-name-help' ) ) .
- $this->getTextBox( 'wgDBmwschema', 'config-db-schema', array( 'dir' => 'ltr' ),
+ $this->getTextBox( 'wgDBmwschema', 'config-db-schema', [ 'dir' => 'ltr' ],
$this->parent->getHelpBox( 'config-db-schema-help' ) ) .
- $this->getTextBox( 'wgDBprefix', 'config-db-prefix', array( 'dir' => 'ltr' ),
+ $this->getTextBox( 'wgDBprefix', 'config-db-prefix', [ 'dir' => 'ltr' ],
$this->parent->getHelpBox( 'config-db-prefix-help' ) ) .
Html::closeElement( 'fieldset' ) .
Html::openElement( 'fieldset' ) .
- Html::element( 'legend', array(), wfMessage( 'config-db-install-account' )->text() ) .
- $this->getRadioSet( array(
+ Html::element( 'legend', [], wfMessage( 'config-db-install-account' )->text() ) .
+ $this->getRadioSet( [
'var' => '_InstallWindowsAuthentication',
'label' => 'config-mssql-auth',
'itemLabelPrefix' => 'config-mssql-',
- 'values' => array( 'sqlauth', 'windowsauth' ),
- 'itemAttribs' => array(
- 'sqlauth' => array(
+ 'values' => [ 'sqlauth', 'windowsauth' ],
+ 'itemAttribs' => [
+ 'sqlauth' => [
'class' => 'showHideRadio',
'rel' => 'dbCredentialBox',
- ),
- 'windowsauth' => array(
+ ],
+ 'windowsauth' => [
'class' => 'hideShowRadio',
'rel' => 'dbCredentialBox',
- )
- ),
+ ]
+ ],
'help' => $this->parent->getHelpBox( 'config-mssql-install-auth' )
- ) ) .
- Html::openElement( 'div', array( 'id' => 'dbCredentialBox', 'style' => $displayStyle ) ) .
+ ] ) .
+ Html::openElement( 'div', [ 'id' => 'dbCredentialBox', 'style' => $displayStyle ] ) .
$this->getTextBox(
'_InstallUser',
'config-db-username',
- array( 'dir' => 'ltr' ),
+ [ 'dir' => 'ltr' ],
$this->parent->getHelpBox( 'config-db-install-username' )
) .
$this->getPasswordBox(
'_InstallPassword',
'config-db-password',
- array( 'dir' => 'ltr' ),
+ [ 'dir' => 'ltr' ],
$this->parent->getHelpBox( 'config-db-install-password' )
) .
Html::closeElement( 'div' ) .
public function submitConnectForm() {
// Get variables from the request.
- $newValues = $this->setVarsFromRequest( array(
+ $newValues = $this->setVarsFromRequest( [
'wgDBserver',
'wgDBname',
'wgDBmwschema',
'wgDBprefix'
- ) );
+ ] );
// Validate them.
$status = Status::newGood();
}
// User box
- $this->setVarsFromRequest( array(
+ $this->setVarsFromRequest( [
'_InstallUser',
'_InstallPassword',
'_InstallWindowsAuthentication'
- ) );
+ ] );
// Try to connect
$status = $this->getConnection();
}
try {
- $db = DatabaseBase::factory( 'mssql', array(
+ $db = DatabaseBase::factory( 'mssql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $user,
'password' => $password,
'dbname' => false,
'flags' => 0,
'schema' => $this->getVar( 'wgDBmwschema' ),
- 'tablePrefix' => $this->getVar( 'wgDBprefix' ) ) );
+ 'tablePrefix' => $this->getVar( 'wgDBprefix' ) ] );
$db->prepareStatements( false );
$db->scrollableCursor( false );
$status->value = $db;
// We need the server-level ALTER ANY LOGIN permission to create new accounts
$res = $conn->query( "SELECT permission_name FROM sys.fn_my_permissions( NULL, 'SERVER' )" );
- $serverPrivs = array(
+ $serverPrivs = [
'ALTER ANY LOGIN' => false,
'CONTROL SERVER' => false,
- );
+ ];
foreach ( $res as $row ) {
$serverPrivs[$row->permission_name] = true;
// and just check for the permission
// http://technet.microsoft.com/en-us/library/ms178569.aspx
// The following array sets up which permissions imply whatever permissions we specify
- $implied = array(
+ $implied = [
// schema database server
- 'DELETE' => array( 'DELETE', 'CONTROL SERVER' ),
- 'EXECUTE' => array( 'EXECUTE', 'CONTROL SERVER' ),
- 'INSERT' => array( 'INSERT', 'CONTROL SERVER' ),
- 'SELECT' => array( 'SELECT', 'CONTROL SERVER' ),
- 'UPDATE' => array( 'UPDATE', 'CONTROL SERVER' ),
- );
+ 'DELETE' => [ 'DELETE', 'CONTROL SERVER' ],
+ 'EXECUTE' => [ 'EXECUTE', 'CONTROL SERVER' ],
+ 'INSERT' => [ 'INSERT', 'CONTROL SERVER' ],
+ 'SELECT' => [ 'SELECT', 'CONTROL SERVER' ],
+ 'UPDATE' => [ 'UPDATE', 'CONTROL SERVER' ],
+ ];
$grantOptions = array_flip( $this->webUserPrivs );
// Check for schema and db-level permissions, but only if the schema/db exists
- $schemaPrivs = $dbPrivs = array(
+ $schemaPrivs = $dbPrivs = [
'DELETE' => false,
'EXECUTE' => false,
'INSERT' => false,
'SELECT' => false,
'UPDATE' => false,
- );
+ ];
$dbPrivs['ALTER ANY USER'] = false;
? 'display: none'
: '';
$s = Html::openElement( 'fieldset' ) .
- Html::element( 'legend', array(), wfMessage( 'config-db-web-account' )->text() ) .
+ Html::element( 'legend', [], wfMessage( 'config-db-web-account' )->text() ) .
$this->getCheckBox(
'_SameAccount', 'config-db-web-account-same',
- array( 'class' => 'hideShowRadio', 'rel' => 'dbOtherAccount' )
+ [ 'class' => 'hideShowRadio', 'rel' => 'dbOtherAccount' ]
) .
- Html::openElement( 'div', array( 'id' => 'dbOtherAccount', 'style' => $wrapperStyle ) ) .
- $this->getRadioSet( array(
+ Html::openElement( 'div', [ 'id' => 'dbOtherAccount', 'style' => $wrapperStyle ] ) .
+ $this->getRadioSet( [
'var' => '_WebWindowsAuthentication',
'label' => 'config-mssql-auth',
'itemLabelPrefix' => 'config-mssql-',
- 'values' => array( 'sqlauth', 'windowsauth' ),
- 'itemAttribs' => array(
- 'sqlauth' => array(
+ 'values' => [ 'sqlauth', 'windowsauth' ],
+ 'itemAttribs' => [
+ 'sqlauth' => [
'class' => 'showHideRadio',
'rel' => 'dbCredentialBox',
- ),
- 'windowsauth' => array(
+ ],
+ 'windowsauth' => [
'class' => 'hideShowRadio',
'rel' => 'dbCredentialBox',
- )
- ),
+ ]
+ ],
'help' => $this->parent->getHelpBox( 'config-mssql-web-auth' )
- ) ) .
- Html::openElement( 'div', array( 'id' => 'dbCredentialBox', 'style' => $displayStyle ) ) .
+ ] ) .
+ Html::openElement( 'div', [ 'id' => 'dbCredentialBox', 'style' => $displayStyle ] ) .
$this->getTextBox( 'wgDBuser', 'config-db-username' ) .
$this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) .
Html::closeElement( 'div' );
* @return Status
*/
public function submitSettingsForm() {
- $this->setVarsFromRequest( array(
+ $this->setVarsFromRequest( [
'wgDBuser',
'wgDBpassword',
'_SameAccount',
'_CreateDBAccount',
'_WebWindowsAuthentication'
- ) );
+ ] );
if ( $this->getVar( '_SameAccount' ) ) {
$this->setVar( '_WebWindowsAuthentication', $this->getVar( '_InstallWindowsAuthentication' ) );
}
try {
- DatabaseBase::factory( 'mssql', array(
+ DatabaseBase::factory( 'mssql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $user,
'password' => $password,
'flags' => 0,
'tablePrefix' => $this->getVar( 'wgDBprefix' ),
'schema' => $this->getVar( 'wgDBmwschema' ),
- ) );
+ ] );
} catch ( DBConnectionError $e ) {
return Status::newFatal( 'config-connection-error', $e->getMessage() );
}
public function preInstall() {
# Add our user callback to installSteps, right before the tables are created.
- $callback = array(
+ $callback = [
'name' => 'user',
- 'callback' => array( $this, 'setupUser' ),
- );
+ 'callback' => [ $this, 'setupUser' ],
+ ];
$this->parent->addInstallStep( $callback, 'tables' );
}
$escUser = $this->db->addIdentifierQuotes( $dbUser );
$escDb = $this->db->addIdentifierQuotes( $dbName );
$escSchema = $this->db->addIdentifierQuotes( $schemaName );
- $grantableNames = array();
+ $grantableNames = [];
if ( $tryToCreate ) {
$escPass = $this->db->addQuotes( $password );
foreach ( $grantableNames as $name ) {
try {
// First try to grant full permissions
- $fullPrivArr = array(
+ $fullPrivArr = [
'BACKUP DATABASE', 'BACKUP LOG', 'CREATE FUNCTION', 'CREATE PROCEDURE',
'CREATE TABLE', 'CREATE VIEW', 'CREATE FULLTEXT CATALOG', 'SHOWPLAN'
- );
+ ];
$fullPrivList = implode( ', ', $fullPrivArr );
$this->db->begin();
$this->db->query( "GRANT $fullPrivList ON DATABASE :: $escDb TO $escUser", __METHOD__ );
public function getGlobalDefaults() {
// The default $wgDBmwschema is null, which breaks Postgres and other DBMSes that require
// the use of a schema, so we need to set it here
- return array_merge( parent::getGlobalDefaults(), array(
+ return array_merge( parent::getGlobalDefaults(), [
'wgDBmwschema' => 'mediawiki',
- ) );
+ ] );
}
/**
* @return bool
*/
private function loginExists( $user ) {
- $res = $this->db->selectField( 'sys.sql_logins', 1, array( 'name' => $user ) );
+ $res = $this->db->selectField( 'sys.sql_logins', 1, [ 'name' => $user ] );
return (bool)$res;
}
* @return bool
*/
private function userExists( $user ) {
- $res = $this->db->selectField( 'sys.sysusers', 1, array( 'name' => $user ) );
+ $res = $this->db->selectField( 'sys.sysusers', 1, [ 'name' => $user ] );
return (bool)$res;
}
* @return bool
*/
private function databaseExists( $dbName ) {
- $res = $this->db->selectField( 'sys.databases', 1, array( 'name' => $dbName ) );
+ $res = $this->db->selectField( 'sys.databases', 1, [ 'name' => $dbName ] );
return (bool)$res;
}
* @return bool
*/
private function schemaExists( $schemaName ) {
- $res = $this->db->selectField( 'sys.schemas', 1, array( 'name' => $schemaName ) );
+ $res = $this->db->selectField( 'sys.schemas', 1, [ 'name' => $schemaName ] );
return (bool)$res;
}
* @return bool
*/
private function catalogExists( $catalogName ) {
- $res = $this->db->selectField( 'sys.fulltext_catalogs', 1, array( 'name' => $catalogName ) );
+ $res = $this->db->selectField( 'sys.fulltext_catalogs', 1, [ 'name' => $catalogName ] );
return (bool)$res;
}
* @return array
*/
public function getSchemaVars() {
- return array(
+ return [
'wgDBname' => $this->getVar( 'wgDBname' ),
'wgDBmwschema' => $this->getVar( 'wgDBmwschema' ),
'wgDBuser' => $this->getVar( 'wgDBuser' ),
'wgDBpassword' => $this->getVar( 'wgDBpassword' ),
- );
+ ];
}
public function getLocalSettings() {