<?php
/**
- * Implements Special:Confirmemail and Special:Invalidateemail
+ * Implements Special:Confirmemail
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
parent::__construct( 'Confirmemail', 'editmyprivateinfo' );
}
+ public function doesWrites() {
+ return true;
+ }
+
/**
* Main execution point
*
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();
+ $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' ) ) {
}
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 );
}
}
$out = $this->getOutput();
if ( !$user->isEmailConfirmed() ) {
- $descriptor = array();
+ $descriptor = [];
if ( $user->isEmailConfirmationPending() ) {
- $descriptor += array(
- 'pending' => array(
+ $descriptor += [
+ 'pending' => [
'type' => 'info',
'raw' => true,
'default' => "<div class=\"error mw-confirmemail-pending\">\n" .
$this->msg( 'confirmemail_pending' )->escaped() .
"\n</div>",
- ),
- );
+ ],
+ ];
}
$out->addWikiMsg( 'confirmemail_text' );
->setMethod( 'post' )
->setAction( $this->getPageTitle()->getLocalURL() )
->setSubmitTextMsg( 'confirmemail_send' )
- ->setSubmitCallback( array( $this, 'submitSend' ) );
+ ->setSubmitCallback( [ $this, 'submitSend' ] );
$retval = $form->show();
*
* @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' );
}
}
}
-
-/**
- * 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();
- }
- }
-}