| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
require_once __DIR__ . '/Maintenance.php'; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class RenameRestrictions extends Maintenance { |
| 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 |
|
| 65 |
$maintClass = RenameRestrictions::class; |
| 66 |
require_once RUN_MAINTENANCE_IF_MAIN; |
| 67 |
|