MediaWiki  REL1_22
patchSql.php
Go to the documentation of this file.
00001 <?php
00025 require_once __DIR__ . '/Maintenance.php';
00026 
00032 class PatchSql extends Maintenance {
00033     public function __construct() {
00034         parent::__construct();
00035         $this->mDescription = "Run an SQL file into the DB, replacing prefix and charset vars";
00036         $this->addArg( 'patch-name', 'Name of the patch file, either full path or in maintenance/archives' );
00037     }
00038 
00039     public function getDbType() {
00040         return Maintenance::DB_ADMIN;
00041     }
00042 
00043     public function execute() {
00044         $dbw = wfGetDB( DB_MASTER );
00045         foreach ( $this->mArgs as $arg ) {
00046             $files = array(
00047                 $arg,
00048                 $dbw->patchPath( $arg ),
00049                 $dbw->patchPath( "patch-$arg.sql" ),
00050             );
00051             foreach ( $files as $file ) {
00052                 if ( file_exists( $file ) ) {
00053                     $this->output( "$file ...\n" );
00054                     $dbw->sourceFile( $file );
00055                     continue 2;
00056                 }
00057             }
00058             $this->error( "Could not find $arg\n" );
00059         }
00060         $this->output( "done.\n" );
00061     }
00062 }
00063 
00064 $maintClass = "PatchSql";
00065 require_once RUN_MAINTENANCE_IF_MAIN;