X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fprotect.php;h=449a7ad6f0bf9812616881417398002147ec81de;hb=d03cfd3fa90b750bcaec1b72d23f917090fc04a1;hp=8f4caa839ead16bbe3a2b3938b4c77e1f5570aa8;hpb=d8cb9695c6971975692808bb7cdc991e2abda0ab;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/protect.php b/maintenance/protect.php index 8f4caa839e..449a7ad6f0 100644 --- a/maintenance/protect.php +++ b/maintenance/protect.php @@ -21,7 +21,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/Maintenance.php' ); +require_once __DIR__ . '/Maintenance.php'; /** * Maintenance script that protects or unprotects a page. @@ -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 ); } @@ -86,4 +90,4 @@ class Protect extends Maintenance { } $maintClass = "Protect"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN;