MediaWiki master
PostgresPlTask.php
Go to the documentation of this file.
1<?php
2
4
8
14class PostgresPlTask extends Task {
15 public function getName() {
16 return 'pg-plpgsql';
17 }
18
19 public function execute(): Status {
20 // Connect as the install user, since it owns the database and so is
21 // the user that needs to run "CREATE EXTENSION"
22 $status = $this->getConnection( ITaskContext::CONN_CREATE_SCHEMA );
23 if ( !$status->isOK() ) {
24 return $status;
25 }
26 $conn = $status->getDB();
27 try {
28 $conn->query( 'CREATE EXTENSION IF NOT EXISTS plpgsql', __METHOD__ );
29 } catch ( DBQueryError $e ) {
30 return Status::newFatal( 'config-pg-no-plpgsql', $this->getConfigVar( MainConfigNames::DBname ) );
31 }
32 return Status::newGood();
33 }
34}
Enable PL/pgSQL in the wiki's database if necessary.
getName()
Get the symbolic name of the task.
Base class for installer tasks.
Definition Task.php:24
getConfigVar(string $name)
Get a configuration variable for the wiki being created.
Definition Task.php:182
getConnection(string $type)
Connect to the database for a specified purpose.
Definition Task.php:202
A class containing constants representing the names of configuration variables.
const DBname
Name constant for the DBname setting, for use with Config::get()
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:54
Dependency bundle and execution context for installer tasks.