MediaWiki  REL1_24
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(
00037             'patch-name',
00038             'Name of the patch file, either full path or in maintenance/archives'
00039         );
00040     }
00041 
00042     public function getDbType() {
00043         return Maintenance::DB_ADMIN;
00044     }
00045 
00046     public function execute() {
00047         $dbw = wfGetDB( DB_MASTER );
00048         foreach ( $this->mArgs as $arg ) {
00049             $files = array(
00050                 $arg,
00051                 $dbw->patchPath( $arg ),
00052                 $dbw->patchPath( "patch-$arg.sql" ),
00053             );
00054             foreach ( $files as $file ) {
00055                 if ( file_exists( $file ) ) {
00056                     $this->output( "$file ...\n" );
00057                     $dbw->sourceFile( $file );
00058                     continue 2;
00059                 }
00060             }
00061             $this->error( "Could not find $arg\n" );
00062         }
00063         $this->output( "done.\n" );
00064     }
00065 }
00066 
00067 $maintClass = "PatchSql";
00068 require_once RUN_MAINTENANCE_IF_MAIN;