Merge "Followup to I5b47e5a"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 15 Nov 2016 03:05:00 +0000 (03:05 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 15 Nov 2016 03:05:00 +0000 (03:05 +0000)
1  2 
includes/specials/SpecialPasswordReset.php

@@@ -34,7 -34,7 +34,7 @@@ use MediaWiki\Auth\AuthManager
   */
  class SpecialPasswordReset extends FormSpecialPage {
        /** @var PasswordReset */
 -      private $passwordReset;
 +      private $passwordReset = null;
  
        /**
         * @var string[] Temporary storage for the passwords which have been sent out, keyed by username.
  
        public function __construct() {
                parent::__construct( 'PasswordReset', 'editmyprivateinfo' );
 -              $this->passwordReset = new PasswordReset( $this->getConfig(), AuthManager::singleton() );
 +      }
 +
 +      private function getPasswordReset() {
 +              if ( $this->passwordReset === null ) {
 +                      $this->passwordReset = new PasswordReset( $this->getConfig(), AuthManager::singleton() );
 +              }
 +              return $this->passwordReset;
        }
  
        public function doesWrites() {
        }
  
        public function userCanExecute( User $user ) {
 -              return $this->passwordReset->isAllowed( $user )->isGood();
 +              return $this->getPasswordReset()->isAllowed( $user )->isGood();
        }
  
        public function checkExecutePermissions( User $user ) {
 -              $status = Status::wrap( $this->passwordReset->isAllowed( $user ) );
 +              $status = Status::wrap( $this->getPasswordReset()->isAllowed( $user ) );
                if ( !$status->isGood() ) {
                        throw new ErrorPageError( 'internalerror', $status->getMessage() );
                }
  
                $this->method = $username ? 'username' : 'email';
                $this->result = Status::wrap(
 -                      $this->passwordReset->execute( $this->getUser(), $username, $email, $capture ) );
 +                      $this->getPasswordReset()->execute( $this->getUser(), $username, $email, $capture ) );
                if ( $capture && $this->result->isOK() ) {
                        $this->passwords = $this->result->getValue();
                }
  
        public function onSuccess() {
                if ( $this->getUser()->isAllowed( 'passwordreset' ) && $this->passwords ) {
-                       // @todo Logging
                        if ( $this->result->isGood() ) {
                                $this->getOutput()->addWikiMsg( 'passwordreset-emailsent-capture2',
                                        count( $this->passwords ) );
         * @return bool
         */
        public function isListed() {
 -              if ( $this->passwordReset->isAllowed( $this->getUser() )->isGood() ) {
 +              if ( $this->getPasswordReset()->isAllowed( $this->getUser() )->isGood() ) {
                        return parent::isListed();
                }