MediaWiki  1.23.12
patchSql.php
Go to the documentation of this file.
1 <?php
25 require_once __DIR__ . '/Maintenance.php';
26 
32 class PatchSql extends Maintenance {
33  public function __construct() {
34  parent::__construct();
35  $this->mDescription = "Run an SQL file into the DB, replacing prefix and charset vars";
36  $this->addArg( 'patch-name', 'Name of the patch file, either full path or in maintenance/archives' );
37  }
38 
39  public function getDbType() {
40  return Maintenance::DB_ADMIN;
41  }
42 
43  public function execute() {
44  $dbw = wfGetDB( DB_MASTER );
45  foreach ( $this->mArgs as $arg ) {
46  $files = array(
47  $arg,
48  $dbw->patchPath( $arg ),
49  $dbw->patchPath( "patch-$arg.sql" ),
50  );
51  foreach ( $files as $file ) {
52  if ( file_exists( $file ) ) {
53  $this->output( "$file ...\n" );
54  $dbw->sourceFile( $file );
55  continue 2;
56  }
57  }
58  $this->error( "Could not find $arg\n" );
59  }
60  $this->output( "done.\n" );
61  }
62 }
63 
64 $maintClass = "PatchSql";
65 require_once RUN_MAINTENANCE_IF_MAIN;
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$files
$files
Definition: importImages.php:67
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3706
PatchSql
Maintenance script that manually runs an SQL patch outside of the general updaters.
Definition: patchSql.php:32
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
PatchSql\execute
execute()
Do the actual work.
Definition: patchSql.php:43
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Maintenance\DB_ADMIN
const DB_ADMIN
Definition: Maintenance.php:59
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:207
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
PatchSql\getDbType
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition: patchSql.php:39
$maintClass
$maintClass
Definition: patchSql.php:64
PatchSql\__construct
__construct()
Default constructor.
Definition: patchSql.php:33