From e13d31e2ab58af0f3fb22bf1827e333a922f262b Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 22 Jun 2015 12:24:21 -0700 Subject: [PATCH] Moved up shouldCheck() short-circuit logic a bit Change-Id: Idbae820131eba8427075c9a59292ecf243490543 --- SimpleCaptcha/Captcha.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) mode change 100644 => 100755 SimpleCaptcha/Captcha.php diff --git a/SimpleCaptcha/Captcha.php b/SimpleCaptcha/Captcha.php old mode 100644 new mode 100755 index 997d4cee1..dd4df4379 --- a/SimpleCaptcha/Captcha.php +++ b/SimpleCaptcha/Captcha.php @@ -289,6 +289,18 @@ class SimpleCaptcha { * @return bool true if the captcha should run */ function shouldCheck( WikiPage $page, $content, $section, $isContent = false, $oldtext = null ) { + global $wgUser, $ceAllowConfirmedEmail; + + if ( $wgUser->isAllowed( 'skipcaptcha' ) ) { + wfDebug( "ConfirmEdit: user group allows skipping captcha\n" ); + return false; + } elseif ( $this->isIPWhitelisted() ) { + return false; + } elseif ( $ceAllowConfirmedEmail && $wgUser->isEmailConfirmed() ) { + wfDebug( "ConfirmEdit: user has confirmed mail, skipping captcha\n" ); + return false; + } + $title = $page->getTitle(); $this->trigger = ''; @@ -311,22 +323,6 @@ class SimpleCaptcha { $isEmpty = $content === ''; } - global $wgUser; - if ( $wgUser->isAllowed( 'skipcaptcha' ) ) { - wfDebug( "ConfirmEdit: user group allows skipping captcha\n" ); - return false; - } - if ( $this->isIPWhitelisted() ) - return false; - - - global $wgEmailAuthentication, $ceAllowConfirmedEmail; - if ( $wgEmailAuthentication && $ceAllowConfirmedEmail && - $wgUser->isEmailConfirmed() ) { - wfDebug( "ConfirmEdit: user has confirmed mail, skipping captcha\n" ); - return false; - } - if ( $this->captchaTriggers( $title, 'edit' ) ) { // Check on all edits global $wgUser;