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