MediaWiki master
renameRestrictions.php
Go to the documentation of this file.
1<?php
11
12// @codeCoverageIgnoreStart
13require_once __DIR__ . '/Maintenance.php';
14// @codeCoverageIgnoreEnd
15
24 public function __construct() {
25 parent::__construct();
26 $this->addDescription( 'Rename a restriction level' );
27 $this->addArg( 'oldlevel', 'Old name of restriction level', true );
28 $this->addArg( 'newlevel', 'New name of restriction level', true );
29 }
30
31 public function execute() {
32 $oldLevel = $this->getArg( 0 );
33 $newLevel = $this->getArg( 1 );
34
35 $dbw = $this->getPrimaryDB();
36 $dbw->newUpdateQueryBuilder()
37 ->update( 'page_restrictions' )
38 ->set( [ 'pr_level' => $newLevel ] )
39 ->where( [ 'pr_level' => $oldLevel ] )
40 ->caller( __METHOD__ )
41 ->execute();
42 $dbw->newUpdateQueryBuilder()
43 ->update( 'protected_titles' )
44 ->set( [ 'pt_create_perm' => $newLevel ] )
45 ->where( [ 'pt_create_perm' => $oldLevel ] )
46 ->caller( __METHOD__ )
47 ->execute();
48 }
49
50}
51
52// @codeCoverageIgnoreStart
53$maintClass = RenameRestrictions::class;
54require_once RUN_MAINTENANCE_IF_MAIN;
55// @codeCoverageIgnoreEnd
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
getPrimaryDB(string|false $virtualDomain=false)
addDescription( $text)
Set the description text.
Maintenance script that updates page_restrictions and protected_titles tables to use a new name for a...
execute()
Do the actual work.
__construct()
Default constructor.