Code cleanups for PageArchive
[lhc/web/wiklou.git] / includes / specials / SpecialConfirmemail.php
index 37d3636..f494b9d 100644 (file)
@@ -34,6 +34,10 @@ class EmailConfirmation extends UnlistedSpecialPage {
                parent::__construct( 'Confirmemail', 'editmyprivateinfo' );
        }
 
+       public function doesWrites() {
+               return true;
+       }
+
        /**
         * Main execution point
         *
@@ -45,15 +49,12 @@ class EmailConfirmation extends UnlistedSpecialPage {
        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' ) ) {
@@ -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' => "<div class=\"error mw-confirmemail-pending\">\n" .
                                                        $this->msg( 'confirmemail_pending' )->escaped() .
                                                        "\n</div>",
-                                       ),
-                               );
+                                       ],
+                               ];
                        }
 
                        $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' );