*
* @var array
*/
- protected $internalDefaults = array();
+ protected $internalDefaults = [];
/**
* Array of MW configuration globals this class uses.
*
* @var array
*/
- protected $globalNames = array();
+ protected $globalNames = [];
/**
* Return the internal name, e.g. 'mysql', or 'sqlite'.
$this->db->begin( __METHOD__ );
$error = $this->db->sourceFile(
- call_user_func( array( $this->db, $sourceFileMethod ) )
+ call_user_func( [ $this->db, $sourceFileMethod ] )
);
if ( $error !== true ) {
$this->db->reportQueryError( $error, 0, '', __METHOD__ );
$this->db->commit( __METHOD__ );
}
// Resume normal operations
- if ( $status->isOk() ) {
+ if ( $status->isOK() ) {
$this->enableLB();
}
}
// Now run updates to create tables for old extensions
- DatabaseUpdater::newForDB( $this->db )->doUpdates( array( 'extensions' ) );
+ DatabaseUpdater::newForDB( $this->db )->doUpdates( [ 'extensions' ] );
return $status;
}
* @return array
*/
public function getSchemaVars() {
- return array();
+ return [];
}
/**
if ( !$status->isOK() ) {
throw new MWException( __METHOD__ . ': unexpected DB connection error' );
}
- LBFactory::setInstance( new LBFactorySingle( array(
- 'connection' => $status->value ) ) );
+
+ \MediaWiki\MediaWikiServices::resetGlobalInstance();
+ $services = \MediaWiki\MediaWikiServices::getInstance();
+
+ $connection = $status->value;
+ $services->redefineService( 'DBLoadBalancerFactory', function() use ( $connection ) {
+ return new LBFactorySingle( [
+ 'connection' => $connection ] );
+ } );
+
}
/**
$this->enableLB();
$ret = true;
- ob_start( array( $this, 'outputHandler' ) );
+ ob_start( [ $this, 'outputHandler' ] );
$up = DatabaseUpdater::newForDB( $this->db );
try {
$up->doUpdates();
* @return array
*/
public function getGlobalDefaults() {
- $defaults = array();
+ $defaults = [];
foreach ( $this->getGlobalNames() as $var ) {
if ( isset( $GLOBALS[$var] ) ) {
$defaults[$var] = $GLOBALS[$var];
* @param string $helpData
* @return string
*/
- public function getTextBox( $var, $label, $attribs = array(), $helpData = "" ) {
+ public function getTextBox( $var, $label, $attribs = [], $helpData = "" ) {
$name = $this->getName() . '_' . $var;
$value = $this->getVar( $var );
if ( !isset( $attribs ) ) {
- $attribs = array();
+ $attribs = [];
}
- return $this->parent->getTextBox( array(
+ return $this->parent->getTextBox( [
'var' => $var,
'label' => $label,
'attribs' => $attribs,
'controlName' => $name,
'value' => $value,
'help' => $helpData
- ) );
+ ] );
}
/**
* @param string $helpData
* @return string
*/
- public function getPasswordBox( $var, $label, $attribs = array(), $helpData = "" ) {
+ public function getPasswordBox( $var, $label, $attribs = [], $helpData = "" ) {
$name = $this->getName() . '_' . $var;
$value = $this->getVar( $var );
if ( !isset( $attribs ) ) {
- $attribs = array();
+ $attribs = [];
}
- return $this->parent->getPasswordBox( array(
+ return $this->parent->getPasswordBox( [
'var' => $var,
'label' => $label,
'attribs' => $attribs,
'controlName' => $name,
'value' => $value,
'help' => $helpData
- ) );
+ ] );
}
/**
* @param string $helpData Optional.
* @return string
*/
- public function getCheckBox( $var, $label, $attribs = array(), $helpData = "" ) {
+ public function getCheckBox( $var, $label, $attribs = [], $helpData = "" ) {
$name = $this->getName() . '_' . $var;
$value = $this->getVar( $var );
- return $this->parent->getCheckBox( array(
+ return $this->parent->getCheckBox( [
'var' => $var,
'label' => $label,
'attribs' => $attribs,
'controlName' => $name,
'value' => $value,
'help' => $helpData
- ) );
+ ] );
}
/**
*/
public function getInstallUserBox() {
return Html::openElement( 'fieldset' ) .
- Html::element( 'legend', array(), wfMessage( 'config-db-install-account' )->text() ) .
+ Html::element( 'legend', [], wfMessage( 'config-db-install-account' )->text() ) .
$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( 'fieldset' );
* @return Status
*/
public function submitInstallUserBox() {
- $this->setVarsFromRequest( array( '_InstallUser', '_InstallPassword' ) );
+ $this->setVarsFromRequest( [ '_InstallUser', '_InstallPassword' ] );
return Status::newGood();
}
public function getWebUserBox( $noCreateMsg = false ) {
$wrapperStyle = $this->getVar( '_SameAccount' ) ? '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 ) ) .
+ Html::openElement( 'div', [ 'id' => 'dbOtherAccount', 'style' => $wrapperStyle ] ) .
$this->getTextBox( 'wgDBuser', 'config-db-username' ) .
$this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) .
$this->parent->getHelpBox( 'config-db-web-help' );
*/
public function submitWebUserBox() {
$this->setVarsFromRequest(
- array( 'wgDBuser', 'wgDBpassword', '_SameAccount', '_CreateDBAccount' )
+ [ 'wgDBuser', 'wgDBpassword', '_SameAccount', '_CreateDBAccount' ]
);
if ( $this->getVar( '_SameAccount' ) ) {
}
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
- if ( $this->db->selectRow( 'interwiki', '*', array(), __METHOD__ ) ) {
+ if ( $this->db->selectRow( 'interwiki', '*', [], __METHOD__ ) ) {
$status->warning( 'config-install-interwiki-exists' );
return $status;
$rows = file( "$IP/maintenance/interwiki.list",
FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
MediaWiki\restoreWarnings();
- $interwikis = array();
+ $interwikis = [];
if ( !$rows ) {
return Status::newFatal( 'config-install-interwiki-list' );
}
}
$row .= "|";
$interwikis[] = array_combine(
- array( 'iw_prefix', 'iw_url', 'iw_local', 'iw_api', 'iw_wikiid' ),
+ [ 'iw_prefix', 'iw_url', 'iw_local', 'iw_api', 'iw_wikiid' ],
explode( '|', $row )
);
}