32use Wikimedia\AtEase\AtEase;
95 if ( version_compare( $serverVersion, static::$minimumVersion ) < 0 ) {
96 return Status::newFatal(
97 static::$notMinimumVersionMessage, static::$minimumVersion, $serverVersion
101 return Status::newGood();
120 return Status::newGood();
156 if ( $status->isOK() ) {
157 $this->db = $status->value;
159 $this->db->clearFlag(
DBO_TRX );
160 $this->db->commit( __METHOD__ );
174 private function stepApplySourceFile(
177 $tableThatMustNotExist =
false
180 if ( !$status->isOK() ) {
185 if ( $tableThatMustNotExist && $this->db->tableExists( $tableThatMustNotExist, __METHOD__ ) ) {
186 $status->warning(
"config-$stepName-tables-exist" );
193 $this->db->begin( __METHOD__ );
195 $error = $this->db->sourceFile(
196 call_user_func( [ $this, $sourceFileMethod ], $this->db )
198 if ( $error !==
true ) {
199 $this->db->reportQueryError( $error, 0,
'', __METHOD__ );
200 $this->db->rollback( __METHOD__ );
201 $status->fatal(
"config-$stepName-tables-failed", $error );
203 $this->db->commit( __METHOD__ );
206 if ( $status->isOK() ) {
219 return $this->stepApplySourceFile(
'getGeneratedSchemaPath',
'install',
'archive' );
228 return $this->stepApplySourceFile(
'getSchemaPath',
'install-manual' );
237 return $this->stepApplySourceFile(
'getUpdateKeysPath',
'updates',
false );
248 private function getSqlFilePath(
$db, $filename ) {
251 $dbmsSpecificFilePath =
"$IP/maintenance/" .
$db->
getType() .
"/$filename";
252 if ( file_exists( $dbmsSpecificFilePath ) ) {
253 return $dbmsSpecificFilePath;
255 return "$IP/maintenance/$filename";
267 return $this->getSqlFilePath(
$db,
'tables.sql' );
277 return $this->getSqlFilePath(
$db,
'tables-generated.sql' );
288 return $this->getSqlFilePath(
$db,
'update-keys.sql' );
297 if ( !$status->isOK() ) {
304 $updater->setAutoExtensionHookContainer( $this->parent->getAutoExtensionHookContainer() );
305 $updater->doUpdates( [
'extensions' ] );
334 if ( $status->isOK() ) {
337 $msg = __METHOD__ .
': unexpected error while establishing'
338 .
' a database connection with message: '
339 . $status->getMessage()->plain();
340 throw new RuntimeException( $msg );
351 if ( !$status->isOK() ) {
352 throw new RuntimeException( __METHOD__ .
': unexpected DB connection error' );
354 $connection = $status->value;
355 $virtualDomains = array_merge(
356 $this->parent->getVirtualDomains(),
357 MWLBFactory::CORE_VIRTUAL_DOMAINS
360 $this->parent->resetMediaWikiServices(
null, [
361 'DBLoadBalancerFactory' =>
static function () use ( $virtualDomains, $connection ) {
362 return LBFactorySingle::newFromConnection(
364 [
'virtualDomains' => $virtualDomains ]
381 ob_start( [ $this,
'outputHandler' ] );
388 echo
"\nAn error occurred:\n";
391 }
catch ( Exception $e ) {
392 echo
"\nAn error occurred:\n";
393 echo $e->getMessage();
440 return extension_loaded( $name );
460 if ( isset( $GLOBALS[$var] ) ) {
461 $defaults[$var] = $GLOBALS[$var];
481 public function getVar( $var, $default =
null ) {
484 if ( isset( $defaults[$var] ) ) {
485 $default = $defaults[$var];
486 } elseif ( isset( $internal[$var] ) ) {
487 $default = $internal[$var];
490 return $this->parent->getVar( $var, $default );
498 public function setVar( $name, $value ) {
499 $this->parent->setVar( $name, $value );
518 if ( !$status->isOK() ) {
531 return $this->db->tableExists(
'cur', __METHOD__ ) ||
532 $this->db->tableExists(
'revision', __METHOD__ );
542 if ( !$status->isOK() ) {
547 $row = $this->db->newSelectQueryBuilder()
549 ->from(
'interwiki' )
550 ->caller( __METHOD__ )->fetchRow();
552 $status->warning(
'config-install-interwiki-exists' );
557 AtEase::suppressWarnings();
558 $rows = file(
"$IP/maintenance/interwiki.list",
559 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
560 AtEase::restoreWarnings();
562 return Status::newFatal(
'config-install-interwiki-list' );
564 $insert = $this->db->newInsertQueryBuilder()
565 ->insertInto(
'interwiki' );
566 foreach ( $rows as $row ) {
567 $row = preg_replace(
'/^\s*([^#]*?)\s*(#.*)?$/',
'\\1', $row );
574 [
'iw_prefix',
'iw_url',
'iw_local',
'iw_api',
'iw_wikiid' ],
579 $insert->caller( __METHOD__ )->execute();
581 return Status::newGood();
585 return htmlspecialchars( $string );
601 ( $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.
getText()
Format plain text message for the current exception object.
MediaWiki-specific class for generating database load balancers.
Class to handle database/schema/prefix specifications for IDatabase.