MediaWiki master
renameRestrictions.php
Go to the documentation of this file.
1<?php
24require_once __DIR__ . '/Maintenance.php';
25
34 public function __construct() {
35 parent::__construct();
36 $this->addDescription( 'Rename a restriction level' );
37 $this->addArg( 'oldlevel', 'Old name of restriction level', true );
38 $this->addArg( 'newlevel', 'New name of restriction level', true );
39 }
40
41 public function execute() {
42 $oldLevel = $this->getArg( 0 );
43 $newLevel = $this->getArg( 1 );
44
45 $dbw = $this->getPrimaryDB();
46 $dbw->newUpdateQueryBuilder()
47 ->update( 'page_restrictions' )
48 ->set( [ 'pr_level' => $newLevel ] )
49 ->where( [ 'pr_level' => $oldLevel ] )
50 ->caller( __METHOD__ )
51 ->execute();
52 $dbw->newUpdateQueryBuilder()
53 ->update( 'protected_titles' )
54 ->set( [ 'pt_create_perm' => $newLevel ] )
55 ->where( [ 'pt_create_perm' => $oldLevel ] )
56 ->caller( __METHOD__ )
57 ->execute();
58 }
59
60}
61
62$maintClass = RenameRestrictions::class;
63require_once RUN_MAINTENANCE_IF_MAIN;
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.
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.