*/
class MysqlInstaller extends DatabaseInstaller {
- protected $globalNames = array(
+ protected $globalNames = [
'wgDBserver',
'wgDBname',
'wgDBuser',
'wgDBprefix',
'wgDBTableOptions',
'wgDBmysql5',
- );
+ ];
- protected $internalDefaults = array(
+ protected $internalDefaults = [
'_MysqlEngine' => 'InnoDB',
'_MysqlCharset' => 'binary',
'_InstallUser' => 'root',
- );
+ ];
- public $supportedEngines = array( 'InnoDB', 'MyISAM' );
+ public $supportedEngines = [ 'InnoDB', 'MyISAM' ];
public $minimumVersion = '5.0.3';
- public $webUserPrivs = array(
+ public $webUserPrivs = [
'DELETE',
'INSERT',
'SELECT',
'UPDATE',
'CREATE TEMPORARY TABLES',
- );
+ ];
/**
* @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( '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' ) .
$this->getInstallUserBox();
public function submitConnectForm() {
// Get variables from the request.
- $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBname', 'wgDBprefix' ) );
+ $newValues = $this->setVarsFromRequest( [ 'wgDBserver', 'wgDBname', 'wgDBprefix' ] );
// Validate them.
$status = Status::newGood();
public function openConnection() {
$status = Status::newGood();
try {
- $db = DatabaseBase::factory( 'mysql', array(
+ $db = DatabaseBase::factory( 'mysql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $this->getVar( '_InstallUser' ),
'password' => $this->getVar( '_InstallPassword' ),
'dbname' => false,
'flags' => 0,
- 'tablePrefix' => $this->getVar( 'wgDBprefix' ) ) );
+ 'tablePrefix' => $this->getVar( 'wgDBprefix' ) ] );
$status->value = $db;
} catch ( DBConnectionError $e ) {
$status->fatal( 'config-connection-error', $e->getMessage() );
*/
$conn = $status->value;
- $engines = array();
+ $engines = [];
$res = $conn->query( 'SHOW ENGINES', __METHOD__ );
foreach ( $res as $row ) {
if ( $row->Support == 'YES' || $row->Support == 'DEFAULT' ) {
* @return array
*/
public function getCharsets() {
- return array( 'binary', 'utf8' );
+ return [ 'binary', 'utf8' ];
}
/**
// The user needs to have INSERT on mysql.* to be able to CREATE USER
// The grantee will be double-quoted in this query, as required
$res = $conn->select( 'INFORMATION_SCHEMA.USER_PRIVILEGES', '*',
- array( 'GRANTEE' => $quotedUser ), __METHOD__ );
+ [ 'GRANTEE' => $quotedUser ], __METHOD__ );
$insertMysql = false;
$grantOptions = array_flip( $this->webUserPrivs );
foreach ( $res as $row ) {
// Check for DB-specific privs for mysql.*
if ( !$insertMysql ) {
$row = $conn->selectRow( 'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES', '*',
- array(
+ [
'GRANTEE' => $quotedUser,
'TABLE_SCHEMA' => 'mysql',
'PRIVILEGE_TYPE' => 'INSERT',
- ), __METHOD__ );
+ ], __METHOD__ );
if ( $row ) {
$insertMysql = true;
}
// Check for DB-level grant options
$res = $conn->select( 'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES', '*',
- array(
+ [
'GRANTEE' => $quotedUser,
'IS_GRANTABLE' => 1,
- ), __METHOD__ );
+ ], __METHOD__ );
foreach ( $res as $row ) {
$regex = $conn->likeToRegex( $row->TABLE_SCHEMA );
if ( preg_match( $regex, $this->getVar( 'wgDBname' ) ) ) {
$this->setVar( '_MysqlEngine', reset( $engines ) );
}
- $s .= Xml::openElement( 'div', array(
+ $s .= Xml::openElement( 'div', [
'id' => 'dbMyisamWarning'
- ) );
+ ] );
$myisamWarning = 'config-mysql-myisam-dep';
if ( count( $engines ) === 1 ) {
$myisamWarning = 'config-mysql-only-myisam-dep';
$s .= Xml::closeElement( 'div' );
if ( $this->getVar( '_MysqlEngine' ) != 'MyISAM' ) {
- $s .= Xml::openElement( 'script', array( 'type' => 'text/javascript' ) );
+ $s .= Xml::openElement( 'script' );
$s .= '$(\'#dbMyisamWarning\').hide();';
$s .= Xml::closeElement( 'script' );
}
// getRadioSet() builds a set of labeled radio buttons.
// For grep: The following messages are used as the item labels:
// config-mysql-innodb, config-mysql-myisam
- $s .= $this->getRadioSet( array(
+ $s .= $this->getRadioSet( [
'var' => '_MysqlEngine',
'label' => 'config-mysql-engine',
'itemLabelPrefix' => 'config-mysql-',
'values' => $engines,
- 'itemAttribs' => array(
- 'MyISAM' => array(
+ 'itemAttribs' => [
+ 'MyISAM' => [
'class' => 'showHideRadio',
'rel' => 'dbMyisamWarning'
- ),
- 'InnoDB' => array(
+ ],
+ 'InnoDB' => [
'class' => 'hideShowRadio',
'rel' => 'dbMyisamWarning'
- )
- )
- ) );
+ ]
+ ]
+ ] );
$s .= $this->parent->getHelpBox( 'config-mysql-engine-help' );
}
// getRadioSet() builds a set of labeled radio buttons.
// For grep: The following messages are used as the item labels:
// config-mysql-binary, config-mysql-utf8
- $s .= $this->getRadioSet( array(
+ $s .= $this->getRadioSet( [
'var' => '_MysqlCharset',
'label' => 'config-mysql-charset',
'itemLabelPrefix' => 'config-mysql-',
'values' => $charsets
- ) );
+ ] );
$s .= $this->parent->getHelpBox( 'config-mysql-charset-help' );
}
* @return Status
*/
public function submitSettingsForm() {
- $this->setVarsFromRequest( array( '_MysqlEngine', '_MysqlCharset' ) );
+ $this->setVarsFromRequest( [ '_MysqlEngine', '_MysqlCharset' ] );
$status = $this->submitWebUserBox();
if ( !$status->isOK() ) {
return $status;
if ( !$create ) {
// Test the web account
try {
- DatabaseBase::factory( 'mysql', array(
+ DatabaseBase::factory( 'mysql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $this->getVar( 'wgDBuser' ),
'password' => $this->getVar( 'wgDBpassword' ),
'dbname' => false,
'flags' => 0,
'tablePrefix' => $this->getVar( 'wgDBprefix' )
- ) );
+ ] );
} 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' );
}
$this->db->selectDB( $dbName );
$server = $this->getVar( 'wgDBserver' );
$password = $this->getVar( 'wgDBpassword' );
- $grantableNames = array();
+ $grantableNames = [];
if ( $this->getVar( '_CreateDBAccount' ) ) {
// Before we blindly try to create a user that already has access,
try { // first attempt to connect to the database
- DatabaseBase::factory( 'mysql', array(
+ DatabaseBase::factory( 'mysql', [
'host' => $server,
'user' => $dbUser,
'password' => $password,
'dbname' => false,
'flags' => 0,
'tablePrefix' => $this->getVar( 'wgDBprefix' )
- ) );
+ ] );
$grantableNames[] = $this->buildFullUserName( $dbUser, $server );
$tryToCreate = false;
} catch ( DBConnectionError $e ) {
}
if ( $tryToCreate ) {
- $createHostList = array(
+ $createHostList = [
$server,
'localhost',
'localhost.localdomain',
'%'
- );
+ ];
$createHostList = array_unique( $createHostList );
$escPass = $this->db->addQuotes( $password );
foreach ( $createHostList as $host ) {
$fullName = $this->buildFullUserName( $dbUser, $host );
- if ( !$this->userDefinitelyExists( $dbUser, $host ) ) {
+ if ( !$this->userDefinitelyExists( $host, $dbUser ) ) {
try {
$this->db->begin( __METHOD__ );
$this->db->query( "CREATE USER $fullName IDENTIFIED BY $escPass", __METHOD__ );
*/
private function userDefinitelyExists( $host, $user ) {
try {
- $res = $this->db->selectRow( 'mysql.user', array( 'Host', 'User' ),
- array( 'Host' => $host, 'User' => $user ), __METHOD__ );
+ $res = $this->db->selectRow( 'mysql.user', [ 'Host', 'User' ],
+ [ 'Host' => $host, 'User' => $user ], __METHOD__ );
return (bool)$res;
} catch ( DBQueryError $dqe ) {
* @return string
*/
protected function getTableOptions() {
- $options = array();
+ $options = [];
if ( $this->getVar( '_MysqlEngine' ) !== null ) {
$options[] = "ENGINE=" . $this->getVar( '_MysqlEngine' );
}
* @return array
*/
public function getSchemaVars() {
- return array(
+ return [
'wgDBTableOptions' => $this->getTableOptions(),
'wgDBname' => $this->getVar( 'wgDBname' ),
'wgDBuser' => $this->getVar( 'wgDBuser' ),
'wgDBpassword' => $this->getVar( 'wgDBpassword' ),
- );
+ ];
}
public function getLocalSettings() {