MediaWiki  master
renameRestrictions.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Maintenance.php';
25 
33  public function __construct() {
34  parent::__construct();
35  $this->addDescription( 'Rename a restriction level' );
36  $this->addArg( 'oldlevel', 'Old name of restriction level', true );
37  $this->addArg( 'newlevel', 'New name of restriction level', true );
38  }
39 
40  public function execute() {
41  $oldLevel = $this->getArg( 0 );
42  $newLevel = $this->getArg( 1 );
43 
44  $dbm = wfGetDB( DB_MASTER );
45  $dbm->update(
46  'page_restrictions',
47  [ 'pr_level' => $newLevel ],
48  [ 'pr_level' => $oldLevel ]
49  );
50  }
51 
52 }
53 
54 $maintClass = RenameRestrictions::class;
55 require_once RUN_MAINTENANCE_IF_MAIN;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:38
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:323
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:53
$maintClass
$maintClass
Definition: renameRestrictions.php:54
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2463
RenameRestrictions\execute
execute()
Do the actual work.
Definition: renameRestrictions.php:40
RenameRestrictions
Maintenance script that updates page_restrictions table with a renamed restriction level.
Definition: renameRestrictions.php:32
DB_MASTER
const DB_MASTER
Definition: defines.php:26
RenameRestrictions\__construct
__construct()
Default constructor.
Definition: renameRestrictions.php:33
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:294
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:347