From 1549d0ec40ee7557fa8b62e11d5a596ef9341988 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sat, 7 Sep 2019 17:46:11 +0200 Subject: [PATCH] Simplify some code by changing single-scope properties to local variables When they're not used outside of the scope where they're defined. Change-Id: I5ca1de8420c1180bf7f5d9f28f2a7402a256adf8 --- includes/upload/UploadFromStash.php | 7 ++----- maintenance/resetUserTokens.php | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/includes/upload/UploadFromStash.php b/includes/upload/UploadFromStash.php index a9f399b7cc..7f4d7c5a5b 100644 --- a/includes/upload/UploadFromStash.php +++ b/includes/upload/UploadFromStash.php @@ -40,14 +40,11 @@ class UploadFromStash extends UploadBase { private $repo; /** - * @param User|bool $user Default: false + * @param User|bool $user Default: false Sometimes this won't exist, as when running from cron. * @param UploadStash|bool $stash Default: false * @param FileRepo|bool $repo Default: false */ public function __construct( $user = false, $stash = false, $repo = false ) { - // user object. sometimes this won't exist, as when running from cron. - $this->user = $user; - if ( $repo ) { $this->repo = $repo; } else { @@ -63,7 +60,7 @@ class UploadFromStash extends UploadBase { wfDebug( __METHOD__ . " creating new UploadStash instance with no user\n" ); } - $this->stash = new UploadStash( $this->repo, $this->user ); + $this->stash = new UploadStash( $this->repo, $user ); } } diff --git a/maintenance/resetUserTokens.php b/maintenance/resetUserTokens.php index 284db2c22e..154482c75a 100644 --- a/maintenance/resetUserTokens.php +++ b/maintenance/resetUserTokens.php @@ -50,10 +50,10 @@ class ResetUserTokens extends Maintenance { } public function execute() { - $this->nullsOnly = $this->getOption( 'nulls' ); + $nullsOnly = $this->getOption( 'nulls' ); if ( !$this->getOption( 'nowarn' ) ) { - if ( $this->nullsOnly ) { + if ( $nullsOnly ) { $this->output( "The script is about to reset the user_token " . "for USERS WITH NULL TOKENS in the database.\n" ); } else { @@ -71,7 +71,7 @@ class ResetUserTokens extends Maintenance { $dbr = $this->getDB( DB_REPLICA ); $where = []; - if ( $this->nullsOnly ) { + if ( $nullsOnly ) { // Have to build this by hand, because \ is escaped in helper functions $where = [ 'user_token = \'' . str_repeat( '\0', 32 ) . '\'' ]; } -- 2.20.1