mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 15:36:58 +00:00
Merge "Move addWiki.php special case to an installer task"
This commit is contained in:
commit
4897e2f2a6
|
@ -1165,5 +1165,10 @@
|
||||||
],
|
],
|
||||||
"ConfigRegistry": {
|
"ConfigRegistry": {
|
||||||
"Echo": "GlobalVarConfig::newInstance"
|
"Echo": "GlobalVarConfig::newInstance"
|
||||||
}
|
},
|
||||||
|
"InstallerTasks": [
|
||||||
|
{
|
||||||
|
"class": "MediaWiki\\Extension\\Notifications\\InstallSchemaTask"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
60
includes/InstallSchemaTask.php
Normal file
60
includes/InstallSchemaTask.php
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MediaWiki\Extension\Notifications;
|
||||||
|
|
||||||
|
use MediaWiki\Installer\Task\Task;
|
||||||
|
use MediaWiki\Status\Status;
|
||||||
|
use Wikimedia\Rdbms\DatabaseDomain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: replace this with virtual domains
|
||||||
|
*
|
||||||
|
* This is a temporary hack to support WMF production wiki creation, with
|
||||||
|
* database creation in an external cluster. Core knows how to do this for
|
||||||
|
* virtual domains, but this extension is not yet using a virtual domain. (T348573)
|
||||||
|
*/
|
||||||
|
class InstallSchemaTask extends Task {
|
||||||
|
public function getName() {
|
||||||
|
return 'echo-schema';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription() {
|
||||||
|
return 'Installing Echo tables';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDependencies() {
|
||||||
|
return [ 'services', 'schema' ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAliases() {
|
||||||
|
// Group with extension tables so that things that depend on
|
||||||
|
// extension tables will have this
|
||||||
|
return 'extension-tables';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(): Status {
|
||||||
|
$cluster = $this->getConfigVar( 'EchoCluster' );
|
||||||
|
if ( !$cluster ) {
|
||||||
|
// This case is adequately handled by LoadExtensionSchemaUpdates
|
||||||
|
return Status::newGood();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the load balancer
|
||||||
|
$lbFactory = $this->getServices()->getDBLoadBalancerFactory();
|
||||||
|
$databaseCreator = $this->getDatabaseCreator();
|
||||||
|
$domainId = $lbFactory->getLocalDomainID();
|
||||||
|
$database = DatabaseDomain::newFromId( $domainId )->getDatabase();
|
||||||
|
$echoLB = $lbFactory->getExternalLB( $cluster );
|
||||||
|
|
||||||
|
// Create database
|
||||||
|
if ( !$databaseCreator->existsInLoadBalancer( $echoLB, $database ) ) {
|
||||||
|
$databaseCreator->createInLoadBalancer( $echoLB, $database );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create tables
|
||||||
|
$dbw = $echoLB->getMaintenanceConnectionRef( DB_PRIMARY );
|
||||||
|
$dbw->setSchemaVars( $this->getContext()->getSchemaVars() );
|
||||||
|
return $this->applySourceFile( $dbw, 'tables-generated.sql' );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue