ApiParse: don't reparse language link titles
[mediawiki.git] / maintenance / patchSql.php
blobc462895f567f6de6abb0d1e17679246ec1c74c85
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.
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.
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.
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
21 * @file
22 * @ingroup Maintenance
25 use MediaWiki\Installer\DatabaseUpdater;
27 // @codeCoverageIgnoreStart
28 require_once __DIR__ . '/Maintenance.php';
29 // @codeCoverageIgnoreEnd
31 /**
32 * Maintenance script that manually runs an SQL patch outside of the general updaters.
34 * @ingroup Maintenance
36 class PatchSql extends Maintenance {
37 public function __construct() {
38 parent::__construct();
39 $this->addDescription( 'Run an SQL file into the DB, replacing prefix and charset vars' );
40 $this->addArg(
41 'patch-name',
42 'Name of the patch file, either full path or in maintenance/archives'
46 public function getDbType() {
47 return Maintenance::DB_ADMIN;
50 public function execute() {
51 $dbw = $this->getDB( DB_PRIMARY );
52 $updater = DatabaseUpdater::newForDB( $dbw, true, $this );
54 foreach ( $this->getArgs() as $name ) {
55 $files = [
56 $name,
57 $updater->patchPath( $dbw, $name ),
58 $updater->patchPath( $dbw, "patch-$name.sql" ),
60 foreach ( $files as $file ) {
61 if ( file_exists( $file ) ) {
62 $this->output( "$file ...\n" );
63 $dbw->sourceFile( $file );
64 continue 2;
67 $this->error( "Could not find $name\n" );
69 $this->output( "done.\n" );
73 // @codeCoverageIgnoreStart
74 $maintClass = PatchSql::class;
75 require_once RUN_MAINTENANCE_IF_MAIN;
76 // @codeCoverageIgnoreEnd