MediaWiki REL1_39
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 = wfGetDB( DB_PRIMARY );
46 $dbw->update(
47 'page_restrictions',
48 [ 'pr_level' => $newLevel ],
49 [ 'pr_level' => $oldLevel ],
50 __METHOD__
51 );
52 $dbw->update(
53 'protected_titles',
54 [ 'pt_create_perm' => $newLevel ],
55 [ 'pt_create_perm' => $oldLevel ],
56 __METHOD__
57 );
58 }
59
60}
61
62$maintClass = RenameRestrictions::class;
63require_once RUN_MAINTENANCE_IF_MAIN;
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
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.
const DB_PRIMARY
Definition defines.php:28