MediaWiki  master
renameRestrictions.php
Go to the documentation of this file.
1 <?php
24 require_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;
63 require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:330
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:60
$maintClass
$maintClass
Definition: renameRestrictions.php:62
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2186
RenameRestrictions\execute
execute()
Do the actual work.
Definition: renameRestrictions.php:41
RenameRestrictions
Maintenance script that updates page_restrictions and protected_titles tables to use a new name for a...
Definition: renameRestrictions.php:33
DB_PRIMARY
const DB_PRIMARY
Definition: defines.php:27
RenameRestrictions\__construct
__construct()
Default constructor.
Definition: renameRestrictions.php:34
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:301
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:354