[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Manually run an SQL patch outside of the general updaters. 4 * This ensures that the DB options (charset, prefix, engine) are correctly set. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License along 17 * with this program; if not, write to the Free Software Foundation, Inc., 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 * http://www.gnu.org/copyleft/gpl.html 20 * 21 * @file 22 * @ingroup Maintenance 23 */ 24 25 require_once __DIR__ . '/Maintenance.php'; 26 27 /** 28 * Maintenance script that manually runs an SQL patch outside of the general updaters. 29 * 30 * @ingroup Maintenance 31 */ 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( 37 'patch-name', 38 'Name of the patch file, either full path or in maintenance/archives' 39 ); 40 } 41 42 public function getDbType() { 43 return Maintenance::DB_ADMIN; 44 } 45 46 public function execute() { 47 $dbw = wfGetDB( DB_MASTER ); 48 foreach ( $this->mArgs as $arg ) { 49 $files = array( 50 $arg, 51 $dbw->patchPath( $arg ), 52 $dbw->patchPath( "patch-$arg.sql" ), 53 ); 54 foreach ( $files as $file ) { 55 if ( file_exists( $file ) ) { 56 $this->output( "$file ...\n" ); 57 $dbw->sourceFile( $file ); 58 continue 2; 59 } 60 } 61 $this->error( "Could not find $arg\n" ); 62 } 63 $this->output( "done.\n" ); 64 } 65 } 66 67 $maintClass = "PatchSql"; 68 require_once RUN_MAINTENANCE_IF_MAIN;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |