MediaWiki master
CreateTablesTask.php
Go to the documentation of this file.
1<?php
2
4
6
12class CreateTablesTask extends Task {
14 public function getName() {
15 return 'tables';
16 }
17
19 public function getDependencies() {
20 return 'schema';
21 }
22
23 public function execute(): Status {
24 $status = $this->getConnection( ITaskContext::CONN_CREATE_TABLES );
25 if ( !$status->isOK() ) {
26 return $status;
27 }
28 $conn = $status->getDB();
29 if ( $conn->tableExists( 'archive', __METHOD__ ) ) {
30 $status->warning( "config-install-tables-exist" );
31 return $status;
32 }
33 $status = $this->applySourceFile( $conn, 'tables-generated.sql' );
34 if ( !$status->isOK() ) {
35 return $status;
36 }
37 // TODO Make this optional, not every DB type has a tables.sql file.
38 $status->merge( $this->applySourceFile( $conn, 'tables.sql' ) );
39 return $status;
40 }
41}
getDependencies()
Get a list of names or aliases of tasks that must be done prior to this task.to override string|strin...
getName()
Get the symbolic name of the task.string
Base class for installer tasks.
Definition Task.php:24
getConnection(string $type)
Connect to the database for a specified purpose.
Definition Task.php:200
applySourceFile(IMaintainableDatabase $conn, string $relPath)
Apply a SQL source file to the database as part of running an installation step.
Definition Task.php:227
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:44
warning( $message,... $parameters)
Add a new warning.
Dependency bundle and execution context for installer tasks.