MediaWiki master
MediaWiki\Installer\Task\Task Class Reference

Base class for installer tasks. More...

Inherited by MediaWiki\Installer\Task\AddWikiRestoredServicesProvider, MediaWiki\Installer\Task\CallbackTask, MediaWiki\Installer\Task\CannedProvider, MediaWiki\Installer\Task\CreateDatabaseTask, MediaWiki\Installer\Task\CreateExternalDomainsTask, MediaWiki\Installer\Task\CreateSysopTask, MediaWiki\Installer\Task\CreateTablesTask, MediaWiki\Installer\Task\ExtensionTablesTask, MediaWiki\Installer\Task\ExtensionsProvider, MediaWiki\Installer\Task\InitialContentTask, MediaWiki\Installer\Task\InsertUpdateKeysTask, MediaWiki\Installer\Task\MailingListSubscribeTask, MediaWiki\Installer\Task\MysqlCreateUserTask, MediaWiki\Installer\Task\PopulateInterwikiTask, MediaWiki\Installer\Task\PopulateSiteStatsTask, MediaWiki\Installer\Task\PostgresCreateSchemaTask, MediaWiki\Installer\Task\PostgresCreateUserTask, MediaWiki\Installer\Task\PostgresPlTask, MediaWiki\Installer\Task\RestoredServicesProvider, MediaWiki\Installer\Task\SqliteCreateDatabaseTask, and MediaWiki\Installer\Task\SqliteCreateSearchIndexTask.

Public Member Functions

 execute ()
 Execute the task.
 
 getAliases ()
 Get alternative names of this task.
 
 getDependencies ()
 Get a list of names or aliases of tasks that must be done prior to this task.
 
 getDescription ()
 Get a human-readable description of what this task does, for use as a progress message.
 
 getDescriptionMessage ()
 Get the description as a Message object.
 
 getHookContainer ()
 Get a HookContainer suitable for calling LoadExtensionSchemaUpdates.
 
 getName ()
 Get the symbolic name of the task.
 
 getProvidedNames ()
 Get a list of names of objects that this task promises to provide via $this->getContext()->provide().
 
 getServices ()
 Get the restored services.
 
 getVirtualDomains ()
 
 initBase (ITaskContext $context, string $schemaBasePath)
 Inject the base class dependencies and configuration.
 
 isPostInstall ()
 If this returns true, the task will be scheduled after tasks for which it returns false.
 
 isSkipped ()
 Override this to return true to skip the task.
 

Protected Member Functions

 applySourceFile (IMaintainableDatabase $conn, string $relPath)
 Apply a SQL source file to the database as part of running an installation step.
 
 definitelyGetConnection (string $type)
 Get a database connection, and throw if a connection could not be obtained.
 
 getConfigVar (string $name)
 Get a configuration variable for the wiki being created.
 
 getConnection (string $type)
 Connect to the database for a specified purpose.
 
 getContext ()
 Get the execution context.
 
 getDatabaseCreator ()
 Get a helper for creating databases.
 
 getOption (string $name)
 Get an installer option value.
 
 getSchemaBasePath ()
 Get the absolute base path for SQL schema files.
 
 getSqlFilePath (string $filename)
 Return a path to the DBMS-specific SQL file if it exists, otherwise default SQL file.
 

Detailed Description

Base class for installer tasks.

Stability: stable
to extend
Since
1.44

Definition at line 24 of file Task.php.

Member Function Documentation

◆ applySourceFile()

MediaWiki\Installer\Task\Task::applySourceFile ( IMaintainableDatabase $conn,
string $relPath )
protected

Apply a SQL source file to the database as part of running an installation step.

Parameters
IMaintainableDatabase$conn
string$relPath
Returns
Status

Definition at line 229 of file Task.php.

References $path, Wikimedia\Rdbms\IDatabase\doAtomicSection(), and Wikimedia\Rdbms\IMaintainableDatabase\sourceFile().

◆ definitelyGetConnection()

MediaWiki\Installer\Task\Task::definitelyGetConnection ( string $type)
protected

Get a database connection, and throw if a connection could not be obtained.

This is for the convenience of callers which expect a connection to already be cached.

Parameters
string$type
Returns
IMaintainableDatabase

Definition at line 214 of file Task.php.

◆ execute()

MediaWiki\Installer\Task\Task::execute ( )
abstract

Execute the task.

Notes for implementors:

  • Unless the task is registered with a specific profile, tasks will run in both installPreConfigured.php and the traditional unconfigured environment. The global state differs between these environments.
  • Tasks almost always have dependencies. Override getDependencies().
  • If you need MediaWikiServices, declare a dependency on 'services' and use getServices(). The dependency ensures that the task is run when the global service container is functional.
Returns
Status

Reimplemented in MediaWiki\Installer\Task\AddWikiRestoredServicesProvider, MediaWiki\Installer\Task\CallbackTask, MediaWiki\Installer\Task\CannedProvider, MediaWiki\Installer\Task\CreateDatabaseTask, MediaWiki\Installer\Task\CreateExternalDomainsTask, MediaWiki\Installer\Task\CreateSysopTask, MediaWiki\Installer\Task\CreateTablesTask, MediaWiki\Installer\Task\ExtensionsProvider, MediaWiki\Installer\Task\ExtensionTablesTask, MediaWiki\Installer\Task\InitialContentTask, MediaWiki\Installer\Task\InsertUpdateKeysTask, MediaWiki\Installer\Task\MailingListSubscribeTask, MediaWiki\Installer\Task\MysqlCreateUserTask, MediaWiki\Installer\Task\PopulateInterwikiTask, MediaWiki\Installer\Task\PopulateSiteStatsTask, MediaWiki\Installer\Task\PostgresCreateSchemaTask, MediaWiki\Installer\Task\PostgresCreateUserTask, MediaWiki\Installer\Task\PostgresPlTask, MediaWiki\Installer\Task\RestoredServicesProvider, MediaWiki\Installer\Task\SqliteCreateDatabaseTask, and MediaWiki\Installer\Task\SqliteCreateSearchIndexTask.

◆ getAliases()

MediaWiki\Installer\Task\Task::getAliases ( )

Get alternative names of this task.

These aliases can be used to fulfill dependencies of other tasks.

Stability: stable
to override
Returns
string|string[]

Reimplemented in MediaWiki\Installer\Task\CallbackTask, MediaWiki\Installer\Task\CreateDatabaseTask, and MediaWiki\Installer\Task\SqliteCreateDatabaseTask.

Definition at line 111 of file Task.php.

◆ getConfigVar()

MediaWiki\Installer\Task\Task::getConfigVar ( string $name)
protected

Get a configuration variable for the wiki being created.

The name should not have a "wg" prefix.

Parameters
string$name
Returns
mixed

Definition at line 182 of file Task.php.

◆ getConnection()

MediaWiki\Installer\Task\Task::getConnection ( string $type)
protected

Connect to the database for a specified purpose.

Parameters
string$typeOne of the ITaskContext::CONN_* constants.
Returns
ConnectionStatus

Definition at line 202 of file Task.php.

◆ getContext()

MediaWiki\Installer\Task\Task::getContext ( )
protected

Get the execution context.

This will throw if initBase() has not been called.

Returns
ITaskContext

Definition at line 171 of file Task.php.

Referenced by MediaWiki\Installer\Task\CannedProvider\execute(), and MediaWiki\Installer\Task\ExtensionsProvider\execute().

◆ getDatabaseCreator()

MediaWiki\Installer\Task\Task::getDatabaseCreator ( )
protected

Get a helper for creating databases.

Returns
DatabaseCreator

Definition at line 286 of file Task.php.

◆ getDependencies()

◆ getDescription()

MediaWiki\Installer\Task\Task::getDescription ( )

Get a human-readable description of what this task does, for use as a progress message.

This may either be English text or a MessageSpecifier. It is unsafe to use an extension message.

Stability: stable
to override
Returns
MessageSpecifier|string

Reimplemented in MediaWiki\Installer\Task\CallbackTask.

Definition at line 63 of file Task.php.

References MediaWiki\Installer\Task\Task\getName(), and wfMessage().

Referenced by MediaWiki\Installer\Task\Task\getDescriptionMessage().

◆ getDescriptionMessage()

MediaWiki\Installer\Task\Task::getDescriptionMessage ( )
final

Get the description as a Message object.

Access: internal
Returns
Message

Definition at line 81 of file Task.php.

References MediaWiki\Installer\Task\Task\getDescription().

◆ getHookContainer()

MediaWiki\Installer\Task\Task::getHookContainer ( )

Get a HookContainer suitable for calling LoadExtensionSchemaUpdates.

Subclasses that want to call this must declare a dependency on "HookContainer".

Returns
HookContainer

Definition at line 308 of file Task.php.

◆ getName()

◆ getOption()

MediaWiki\Installer\Task\Task::getOption ( string $name)
protected

Get an installer option value.

Parameters
string$name
Returns
mixed

Definition at line 192 of file Task.php.

◆ getProvidedNames()

MediaWiki\Installer\Task\Task::getProvidedNames ( )

Get a list of names of objects that this task promises to provide via $this->getContext()->provide().

If this is non-empty, the task is a scheduled provider, which means that it is not persistently complete after it has been run. If installation is interrupted, it might need to be run again.

Stability: stable
to override
Returns
string|string[]

Reimplemented in MediaWiki\Installer\Task\AddWikiRestoredServicesProvider, MediaWiki\Installer\Task\CannedProvider, MediaWiki\Installer\Task\CreateSysopTask, MediaWiki\Installer\Task\ExtensionsProvider, and MediaWiki\Installer\Task\RestoredServicesProvider.

Definition at line 136 of file Task.php.

◆ getSchemaBasePath()

MediaWiki\Installer\Task\Task::getSchemaBasePath ( )
protected

Get the absolute base path for SQL schema files.

For core tasks, this is $IP/sql. For extension tasks, this will be sql/ under the extension directory.

It would be possible to make the extension path be configurable, but it is currently not needed since extensions typically do not create their tables by this mechanism.

Returns
string

Definition at line 257 of file Task.php.

◆ getServices()

MediaWiki\Installer\Task\Task::getServices ( )

Get the restored services.

Subclasses that want to call this must declare a dependency on "services".

Returns
MediaWikiServices

Definition at line 296 of file Task.php.

◆ getSqlFilePath()

MediaWiki\Installer\Task\Task::getSqlFilePath ( string $filename)
protected

Return a path to the DBMS-specific SQL file if it exists, otherwise default SQL file.

The path should be relative to the core or extension schema base path.

Parameters
string$filename
Returns
string

Definition at line 269 of file Task.php.

◆ getVirtualDomains()

MediaWiki\Installer\Task\Task::getVirtualDomains ( )

Definition at line 320 of file Task.php.

◆ initBase()

MediaWiki\Installer\Task\Task::initBase ( ITaskContext $context,
string $schemaBasePath )
final

Inject the base class dependencies and configuration.

Parameters
ITaskContext$context
string$schemaBasePath

Definition at line 158 of file Task.php.

◆ isPostInstall()

MediaWiki\Installer\Task\Task::isPostInstall ( )

If this returns true, the task will be scheduled after tasks for which it returns false.

Subclasses can override this to return true for tasks that respond to the successful complete installation of the wiki.

Stability: stable
to override
Returns
bool

Reimplemented in MediaWiki\Installer\Task\CallbackTask.

Definition at line 148 of file Task.php.

◆ isSkipped()

MediaWiki\Installer\Task\Task::isSkipped ( )

Override this to return true to skip the task.

If this returns true, execute() will not be called, and start/end messages will not be produced.

Stability: stable
to override
Returns
bool

Reimplemented in MediaWiki\Installer\Task\ExtensionTablesTask, MediaWiki\Installer\Task\MailingListSubscribeTask, MediaWiki\Installer\Task\MysqlCreateUserTask, and MediaWiki\Installer\Task\PostgresCreateUserTask.

Definition at line 100 of file Task.php.


The documentation for this class was generated from the following file: