Merge "resourceloader: Reduce module_deps write slams after deployments"
[lhc/web/wiklou.git] / maintenance / protect.php
index ec03f93..4a3148a 100644 (file)
@@ -31,7 +31,7 @@ require_once __DIR__ . '/Maintenance.php';
 class Protect extends Maintenance {
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Protect or unprotect a page from the command line.";
+               $this->addDescription( 'Protect or unprotect a page from the command line.' );
                $this->addOption( 'unprotect', 'Removes protection' );
                $this->addOption( 'semiprotect', 'Adds semi-protection' );
                $this->addOption( 'cascade', 'Add cascading protection' );
@@ -41,7 +41,7 @@ class Protect extends Maintenance {
        }
 
        public function execute() {
-               $userName = $this->getOption( 'u', 'Maintenance script' );
+               $userName = $this->getOption( 'u', false );
                $reason = $this->getOption( 'r', '' );
 
                $cascade = $this->hasOption( 'cascade' );
@@ -53,7 +53,11 @@ class Protect extends Maintenance {
                        $protection = "";
                }
 
-               $user = User::newFromName( $userName );
+               if ( $userName === false ) {
+                       $user = User::newSystemUser( 'Maintenance script', array( 'steal' => true ) );
+               } else {
+                       $user = User::newFromName( $userName );
+               }
                if ( !$user ) {
                        $this->error( "Invalid username", true );
                }