Merge "Simplify some code by changing single-scope properties to local variables"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 7 Sep 2019 17:42:09 +0000 (17:42 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 7 Sep 2019 17:42:09 +0000 (17:42 +0000)
includes/upload/UploadFromStash.php
maintenance/resetUserTokens.php

index a9f399b..7f4d7c5 100644 (file)
@@ -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 );
                }
        }
 
index 284db2c..154482c 100644 (file)
@@ -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 ) . '\'' ];
                }