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