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