MediaWiki master
PostgresPlTask.php
Go to the documentation of this file.
1<?php
2
4
8
14class PostgresPlTask extends Task {
16 public function getName() {
17 return 'pg-plpgsql';
18 }
19
20 public function execute(): Status {
21 // Connect as the install user, since it owns the database and so is
22 // the user that needs to run "CREATE EXTENSION"
23 $status = $this->getConnection( ITaskContext::CONN_CREATE_SCHEMA );
24 if ( !$status->isOK() ) {
25 return $status;
26 }
27 $conn = $status->getDB();
28 try {
29 $conn->query( 'CREATE EXTENSION IF NOT EXISTS plpgsql', __METHOD__ );
30 } catch ( DBQueryError ) {
31 return Status::newFatal( 'config-pg-no-plpgsql', $this->getConfigVar( MainConfigNames::DBname ) );
32 }
33 return Status::newGood();
34 }
35}
Enable PL/pgSQL in the wiki's database if necessary.
getName()
Get the symbolic name of the task.string
Base class for installer tasks.
Definition Task.php:24
getConfigVar(string $name)
Get a configuration variable for the wiki being created.
Definition Task.php:180
getConnection(string $type)
Connect to the database for a specified purpose.
Definition Task.php:200
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:44
Dependency bundle and execution context for installer tasks.