21 private const CORE_SPECS = [
23 [
'class' => CreateDatabaseTask::class,
'db' =>
'mysql' ],
24 [
'class' => MysqlCreateUserTask::class,
'db' =>
'mysql' ],
25 [
'class' => CreateDatabaseTask::class,
'db' =>
'postgres' ],
26 [
'class' => PostgresCreateUserTask::class,
'db' =>
'postgres' ],
27 [
'class' => PostgresPlTask::class,
'db' =>
'postgres' ],
28 [
'class' => PostgresCreateSchemaTask::class,
'db' =>
'postgres' ],
29 [
'class' => SqliteCreateDatabaseTask::class,
'db' =>
'sqlite' ],
30 [
'class' => SqliteCreateSearchIndexTask::class,
'db' =>
'sqlite' ],
31 [
'class' => CreateTablesTask::class ],
32 [
'class' => PopulateSiteStatsTask::class ],
33 [
'class' => PopulateInterwikiTask::class ],
34 [
'class' => InsertUpdateKeysTask::class ],
38 [
'class' => ExtensionTablesTask::class ],
39 [
'class' => InitialContentTask::class ],
44 private const WEB_UPGRADE_SPECS = [
45 [
'class' => WebUpgradeExtensionsProvider::class ],
46 [
'class' => RestoredServicesProvider::class ],
47 [
'class' => WebUpgradeTask::class ],
51 private $objectFactory;
56 $this->objectFactory = $objectFactory;
57 $this->context = $context;
68 $this->registerTasks( $list, $profile, self::CORE_SPECS );
79 $specs = $this->context->getProvision(
'ExtensionTaskSpecs' );
80 if ( !is_array( $specs ) ) {
81 throw new \RuntimeException(
'Invalid value for ExtensionTaskSpecs' );
83 $this->registerTasks( $list, $profile, $specs );
87 $this->registerTasks( $list, self::PROFILE_WEB_UPGRADE, self::WEB_UPGRADE_SPECS );
97 private function registerTasks(
TaskList $list,
string $profile, array $specs ) {
98 $dbType = $this->context->getDbType();
99 foreach ( $specs as $spec ) {
100 if ( isset( $spec[
'db'] ) && $spec[
'db'] !== $dbType ) {
103 if ( isset( $spec[
'profile'] ) && $spec[
'profile'] !== $profile ) {
129 if ( isset( $spec[
'callback'] ) ) {
132 $allowedParamNames = [
'factory',
'class',
'args' ];
133 $factorySpec = array_intersect_key( $spec, array_fill_keys( $allowedParamNames,
true ) );
134 $task = $this->objectFactory->createObject( $factorySpec );
135 if ( !( $task instanceof
Task ) ) {
136 throw new \RuntimeException(
'Invalid task type' );
140 $schemaBasePath = $spec[
'schemaBasePath'] ?? $this->getCoreSchemaBasePath();
149 private function getCoreSchemaBasePath() {
150 return MW_INSTALL_PATH .
'/sql';