MediaWiki
master
Toggle main menu visibility
patchSql.php
Go to the documentation of this file.
1
<?php
10
11
use
MediaWiki\Installer\DatabaseUpdater
;
12
use
MediaWiki\Maintenance\Maintenance
;
13
14
// @codeCoverageIgnoreStart
15
require_once __DIR__ .
'/Maintenance.php'
;
16
// @codeCoverageIgnoreEnd
17
23
class
PatchSql
extends
Maintenance
{
24
public
function
__construct
() {
25
parent::__construct();
26
$this->addDescription(
'Run an SQL file into the DB, replacing prefix and charset vars'
);
27
$this->addArg(
28
'patch-name'
,
29
'Name of the patch file, either full path or in sql/$dbtype/'
30
);
31
}
32
34
public
function
getDbType
() {
35
return
Maintenance::DB_ADMIN;
36
}
37
38
public
function
execute
() {
39
$dbw = $this->getDB(
DB_PRIMARY
);
40
$updater =
DatabaseUpdater::newForDB
( $dbw,
true
, $this );
41
42
foreach
( $this->getArgs() as $name ) {
43
$files = [
44
$name,
45
$updater->patchPath( $dbw, $name ),
46
$updater->patchPath( $dbw,
"patch-$name.sql"
),
47
];
48
foreach
( $files as $file ) {
49
if
( file_exists( $file ) ) {
50
$this->output(
"$file ...\n"
);
51
$dbw->sourceFile( $file );
52
continue
2;
53
}
54
}
55
$this->error(
"Could not find $name\n"
);
56
}
57
$this->output(
"done.\n"
);
58
}
59
}
60
61
// @codeCoverageIgnoreStart
62
$maintClass
= PatchSql::class;
63
require_once RUN_MAINTENANCE_IF_MAIN;
64
// @codeCoverageIgnoreEnd
DB_PRIMARY
const DB_PRIMARY
Definition
defines.php:28
$maintClass
$maintClass
Definition
addChangeTag.php:56
MediaWiki\Installer\DatabaseUpdater
Apply database changes after updating MediaWiki.
Definition
DatabaseUpdater.php:40
MediaWiki\Installer\DatabaseUpdater\newForDB
static newForDB(IMaintainableDatabase $db, $shared=false, ?Maintenance $maintenance=null)
Definition
DatabaseUpdater.php:196
PatchSql
Maintenance script that manually runs an SQL patch outside of the general updaters.
Definition
patchSql.php:23
PatchSql\getDbType
getDbType()
Definition
patchSql.php:34
PatchSql\__construct
__construct()
Definition
patchSql.php:24
PatchSql\execute
execute()
Definition
patchSql.php:38
MediaWiki\Maintenance
Definition
applyChangeTag.php:11
maintenance
patchSql.php
Generated on
for MediaWiki by
1.18.0