Merge "Moved up shouldCheck() short-circuit logic a bit"

This commit is contained in:
jenkins-bot 2015-06-22 19:40:46 +00:00 committed by Gerrit Code Review
commit 78cc7ffd06

28
SimpleCaptcha/Captcha.php Normal file → Executable file
View file

@ -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;