31use Wikimedia\AtEase\AtEase;
94 if ( version_compare( $serverVersion, static::$minimumVersion ) < 0 ) {
95 return Status::newFatal(
96 static::$notMinimumVersionMessage, static::$minimumVersion, $serverVersion
100 return Status::newGood();
119 return Status::newGood();
155 if ( $status->isOK() ) {
156 $this->db = $status->value;
158 $this->db->clearFlag(
DBO_TRX );
159 $this->db->commit( __METHOD__ );
173 private function stepApplySourceFile(
176 $tableThatMustNotExist =
false
179 if ( !$status->isOK() ) {
184 if ( $tableThatMustNotExist && $this->db->tableExists( $tableThatMustNotExist, __METHOD__ ) ) {
185 $status->warning(
"config-$stepName-tables-exist" );
192 $this->db->begin( __METHOD__ );
194 $error = $this->db->sourceFile(
195 call_user_func( [ $this, $sourceFileMethod ], $this->db )
197 if ( $error !==
true ) {
198 $this->db->reportQueryError( $error, 0,
'', __METHOD__ );
199 $this->db->rollback( __METHOD__ );
200 $status->fatal(
"config-$stepName-tables-failed", $error );
202 $this->db->commit( __METHOD__ );
205 if ( $status->isOK() ) {
218 return $this->stepApplySourceFile(
'getGeneratedSchemaPath',
'install',
'archive' );
227 return $this->stepApplySourceFile(
'getSchemaPath',
'install-manual' );
236 return $this->stepApplySourceFile(
'getUpdateKeysPath',
'updates',
false );
247 private function getSqlFilePath(
$db, $filename ) {
250 $dbmsSpecificFilePath =
"$IP/maintenance/" .
$db->
getType() .
"/$filename";
251 if ( file_exists( $dbmsSpecificFilePath ) ) {
252 return $dbmsSpecificFilePath;
254 return "$IP/maintenance/$filename";
266 return $this->getSqlFilePath(
$db,
'tables.sql' );
276 return $this->getSqlFilePath(
$db,
'tables-generated.sql' );
287 return $this->getSqlFilePath(
$db,
'update-keys.sql' );
296 if ( !$status->isOK() ) {
303 $updater->setAutoExtensionHookContainer( $this->parent->getAutoExtensionHookContainer() );
304 $updater->doUpdates( [
'extensions' ] );
333 if ( $status->isOK() ) {
336 $msg = __METHOD__ .
': unexpected error while establishing'
337 .
' a database connection with message: '
338 . $status->getMessage()->plain();
339 throw new RuntimeException( $msg );
350 if ( !$status->isOK() ) {
351 throw new RuntimeException( __METHOD__ .
': unexpected DB connection error' );
353 $connection = $status->value;
354 $virtualDomains = array_merge(
355 $this->parent->getVirtualDomains(),
356 MWLBFactory::CORE_VIRTUAL_DOMAINS
359 $this->parent->resetMediaWikiServices(
null, [
360 'DBLoadBalancerFactory' =>
static function () use ( $virtualDomains, $connection ) {
361 return LBFactorySingle::newFromConnection(
363 [
'virtualDomains' => $virtualDomains ]
379 ob_start( [ $this,
'outputHandler' ] );
384 }
catch ( Exception $e ) {
386 echo
"\nAn error occurred:\n";
387 echo $e->getMessage();
434 return extension_loaded( $name );
454 if ( isset( $GLOBALS[$var] ) ) {
455 $defaults[$var] = $GLOBALS[$var];
475 public function getVar( $var, $default =
null ) {
478 if ( isset( $defaults[$var] ) ) {
479 $default = $defaults[$var];
480 } elseif ( isset( $internal[$var] ) ) {
481 $default = $internal[$var];
484 return $this->parent->getVar( $var, $default );
492 public function setVar( $name, $value ) {
493 $this->parent->setVar( $name, $value );
512 if ( !$status->isOK() ) {
525 return $this->db->tableExists(
'cur', __METHOD__ ) ||
526 $this->db->tableExists(
'revision', __METHOD__ );
536 if ( !$status->isOK() ) {
541 $row = $this->db->newSelectQueryBuilder()
543 ->from(
'interwiki' )
544 ->caller( __METHOD__ )->fetchRow();
546 $status->warning(
'config-install-interwiki-exists' );
551 AtEase::suppressWarnings();
552 $rows = file(
"$IP/maintenance/interwiki.list",
553 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
554 AtEase::restoreWarnings();
556 return Status::newFatal(
'config-install-interwiki-list' );
558 $insert = $this->db->newInsertQueryBuilder()
559 ->insertInto(
'interwiki' );
560 foreach ( $rows as $row ) {
561 $row = preg_replace(
'/^\s*([^#]*?)\s*(#.*)?$/',
'\\1', $row );
568 [
'iw_prefix',
'iw_url',
'iw_local',
'iw_api',
'iw_wikiid' ],
573 $insert->caller( __METHOD__ )->execute();
575 return Status::newGood();
579 return htmlspecialchars( $string );
595 ( $schema !==
'' ) ? $schema :
null,
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
MediaWiki-specific class for generating database load balancers.
Class to handle database/schema/prefix specifications for IDatabase.