MediaWiki REL1_31
patchSql.php
Go to the documentation of this file.
1<?php
25require_once __DIR__ . '/Maintenance.php';
26
32class PatchSql extends Maintenance {
33 public function __construct() {
34 parent::__construct();
35 $this->addDescription( 'Run an SQL file into the DB, replacing prefix and charset vars' );
36 $this->addArg(
37 'patch-name',
38 'Name of the patch file, either full path or in maintenance/archives'
39 );
40 }
41
42 public function getDbType() {
44 }
45
46 public function execute() {
47 $dbw = $this->getDB( DB_MASTER );
48 $updater = DatabaseUpdater::newForDB( $dbw, true, $this );
49
50 foreach ( $this->mArgs as $arg ) {
51 $files = [
52 $arg,
53 $updater->patchPath( $dbw, $arg ),
54 $updater->patchPath( $dbw, "patch-$arg.sql" ),
55 ];
56 foreach ( $files as $file ) {
57 if ( file_exists( $file ) ) {
58 $this->output( "$file ...\n" );
59 $dbw->sourceFile( $file );
60 continue 2;
61 }
62 }
63 $this->error( "Could not find $arg\n" );
64 }
65 $this->output( "done.\n" );
66 }
67}
68
69$maintClass = PatchSql::class;
70require_once RUN_MAINTENANCE_IF_MAIN;
static newForDB(Database $db, $shared=false, Maintenance $maintenance=null)
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
Add some args that are needed.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
addDescription( $text)
Set the description text.
Maintenance script that manually runs an SQL patch outside of the general updaters.
Definition patchSql.php:32
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition patchSql.php:42
__construct()
Default constructor.
Definition patchSql.php:33
execute()
Do the actual work.
Definition patchSql.php:46
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
Definition hooks.txt:2612
require_once RUN_MAINTENANCE_IF_MAIN
$maintClass
Definition patchSql.php:69
const DB_MASTER
Definition defines.php:29