X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialConfirmemail.php;h=f494b9d666d15a705487ee88566b5a041d3eb2f8;hb=581be97c46c584d04dd0c625cf6d0aa377a9b056;hp=ea26ada08aa927abe724c63a2a17ccbeec1831b2;hpb=e2d6e193c94cb0b9b82654d2365113973dd41ecb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialConfirmemail.php b/includes/specials/SpecialConfirmemail.php index ea26ada08a..f494b9d666 100644 --- a/includes/specials/SpecialConfirmemail.php +++ b/includes/specials/SpecialConfirmemail.php @@ -1,6 +1,6 @@ getTransactionProfiler()->resetExpectations(); + $trxProfiler = Profiler::instance()->getTransactionProfiler(); $this->setHeaders(); - $this->checkReadOnly(); $this->checkPermissions(); - $this->requireLogin( 'confirmemail_needlogin' ); - // This could also let someone check the current email address, so // require both permissions. if ( !$this->getUser()->isAllowed( 'viewmyprivateinfo' ) ) { @@ -61,13 +62,16 @@ class EmailConfirmation extends UnlistedSpecialPage { } if ( $code === null || $code === '' ) { + $this->requireLogin( 'confirmemail_needlogin' ); if ( Sanitizer::validateEmail( $this->getUser()->getEmail() ) ) { $this->showRequestForm(); } else { $this->getOutput()->addWikiMsg( 'confirmemail_noemail' ); } } else { + $old = $trxProfiler->setSilenced( true ); $this->attemptConfirm( $code ); + $trxProfiler->setSilenced( $old ); } } @@ -79,17 +83,17 @@ class EmailConfirmation extends UnlistedSpecialPage { $out = $this->getOutput(); if ( !$user->isEmailConfirmed() ) { - $descriptor = array(); + $descriptor = []; if ( $user->isEmailConfirmationPending() ) { - $descriptor += array( - 'pending' => array( + $descriptor += [ + 'pending' => [ 'type' => 'info', 'raw' => true, 'default' => "
\n" . $this->msg( 'confirmemail_pending' )->escaped() . "\n
", - ), - ); + ], + ]; } $out->addWikiMsg( 'confirmemail_text' ); @@ -98,7 +102,7 @@ class EmailConfirmation extends UnlistedSpecialPage { ->setMethod( 'post' ) ->setAction( $this->getPageTitle()->getLocalURL() ) ->setSubmitTextMsg( 'confirmemail_send' ) - ->setSubmitCallback( array( $this, 'submitSend' ) ); + ->setSubmitCallback( [ $this, 'submitSend' ] ); $retval = $form->show(); @@ -143,7 +147,7 @@ class EmailConfirmation extends UnlistedSpecialPage { * * @param string $code Confirmation code */ - function attemptConfirm( $code ) { + private function attemptConfirm( $code ) { $user = User::newFromConfirmationCode( $code, User::READ_LATEST ); if ( !is_object( $user ) ) { $this->getOutput()->addWikiMsg( 'confirmemail_invalid' ); @@ -162,49 +166,3 @@ class EmailConfirmation extends UnlistedSpecialPage { } } } - -/** - * Special page allows users to cancel an email confirmation using the e-mail - * confirmation code - * - * @ingroup SpecialPage - */ -class EmailInvalidation extends UnlistedSpecialPage { - public function __construct() { - parent::__construct( 'Invalidateemail', 'editmyprivateinfo' ); - } - - function execute( $code ) { - // Ignore things like master queries/connections on GET requests. - // It's very convenient to just allow formless link usage. - Profiler::instance()->getTransactionProfiler()->resetExpectations(); - - $this->setHeaders(); - $this->checkReadOnly(); - $this->checkPermissions(); - $this->attemptInvalidate( $code ); - } - - /** - * Attempt to invalidate the user's email address and show success or failure - * as needed; if successful, link to main page - * - * @param string $code Confirmation code - */ - function attemptInvalidate( $code ) { - $user = User::newFromConfirmationCode( $code, User::READ_LATEST ); - if ( !is_object( $user ) ) { - $this->getOutput()->addWikiMsg( 'confirmemail_invalid' ); - - return; - } - - $user->invalidateEmail(); - $user->saveSettings(); - $this->getOutput()->addWikiMsg( 'confirmemail_invalidated' ); - - if ( !$this->getUser()->isLoggedIn() ) { - $this->getOutput()->returnToMain(); - } - } -}