From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- extensions/ConfirmEdit/Captcha.php | 64 +++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 29 deletions(-) (limited to 'extensions/ConfirmEdit/Captcha.php') diff --git a/extensions/ConfirmEdit/Captcha.php b/extensions/ConfirmEdit/Captcha.php index 3d6494ff..0f78d36f 100644 --- a/extensions/ConfirmEdit/Captcha.php +++ b/extensions/ConfirmEdit/Captcha.php @@ -1,7 +1,6 @@ text(); # Obtain a more tailored message, if possible, otherwise, fall back to # the default for edits - return wfEmptyMsg( $name, $text ) ? wfMsg( 'captcha-edit' ) : $text; + return wfMessage( $name, $text )->isDisabled() ? wfMessage( 'captcha-edit' )->text() : $text; } /** @@ -156,7 +155,8 @@ class SimpleCaptcha { if ( !$count ) { $wgMemc->add( $key, 0, $wgCaptchaBadLoginExpiration ); } - $count = $wgMemc->incr( $key ); + + $wgMemc->incr( $key ); } return true; } @@ -181,8 +181,7 @@ class SimpleCaptcha { if ( $wgCaptchaWhitelistIP ) { global $wgRequest; - // Compat: WebRequest::getIP is only available since MW 1.19. - $ip = method_exists( $wgRequest, 'getIP' ) ? $wgRequest->getIP() : wfGetIP(); + $ip = $wgRequest->getIP(); foreach ( $wgCaptchaWhitelistIP as $range ) { if ( IP::isInRange( $ip, $range ) ) { @@ -200,8 +199,7 @@ class SimpleCaptcha { */ function badLoginKey() { global $wgRequest; - // Compat: WebRequest::getIP is only available since MW 1.19. - $ip = method_exists( $wgRequest, 'getIP' ) ? $wgRequest->getIP() : wfGetIP(); + $ip = $wgRequest->getIP(); return wfMemcKey( 'captcha', 'badlogin', 'ip', $ip ); } @@ -236,9 +234,10 @@ class SimpleCaptcha { } /** - * @param EditPage $editPage - * @param string $newtext - * @param string $section + * @param $editPage EditPage + * @param $newtext string + * @param $section string + * @param $merged bool * @return bool true if the captcha should run */ function shouldCheck( &$editPage, $newtext, $section, $merged = false ) { @@ -316,8 +315,8 @@ class SimpleCaptcha { global $wgCaptchaRegexes; if ( $wgCaptchaRegexes ) { - // Custom regex checks - $oldtext = $this->loadText( $editPage, $section ); + // Custom regex checks. Reuse $oldtext if set above. + $oldtext = isset( $oldtext ) ? $oldtext : $this->loadText( $editPage, $section ); foreach ( $wgCaptchaRegexes as $regex ) { $newMatches = array(); @@ -348,15 +347,15 @@ class SimpleCaptcha { /** * Filter callback function for URL whitelisting - * @param string url to check + * @param $url string to check * @return bool true if unknown, false if whitelisted * @access private */ function filterLink( $url ) { global $wgCaptchaWhitelist; - $source = wfMsgForContent( 'captcha-addurl-whitelist' ); + $source = wfMessage( 'captcha-addurl-whitelist' )->inContentLanguage()->text(); - $whitelist = wfEmptyMsg( 'captcha-addurl-whitelist', $source ) + $whitelist = wfMessage( 'captcha-addurl-whitelist', $source )->isDisabled() ? false : $this->buildRegexes( explode( "\n", $source ) ); @@ -368,7 +367,7 @@ class SimpleCaptcha { /** * Build regex from whitelist - * @param string lines from [[MediaWiki:Captcha-addurl-whitelist]] + * @param $lines string from [[MediaWiki:Captcha-addurl-whitelist]] * @return string Regex or bool false if whitelist is empty * @access private */ @@ -433,6 +432,10 @@ class SimpleCaptcha { /** * Backend function for confirmEdit() and confirmEditAPI() + * @param $editPage EditPage + * @param $newtext string + * @param $section + * @param $merged bool * @return bool false if the CAPTCHA is rejected, true otherwise */ private function doConfirmEdit( $editPage, $newtext, $section, $merged = false ) { @@ -476,6 +479,7 @@ class SimpleCaptcha { * A more efficient edit filter callback based on the text after section merging * @param EditPage $editPage * @param string $newtext + * @return bool */ function confirmEditMerged( $editPage, $newtext ) { return $this->confirmEdit( $editPage, $newtext, false, true ); @@ -508,7 +512,7 @@ class SimpleCaptcha { $this->trigger = "new account '" . $u->getName() . "'"; if ( !$this->passCaptcha() ) { - $message = wfMsg( 'captcha-createaccount-fail' ); + $message = wfMessage( 'captcha-createaccount-fail' )->text(); return false; } } @@ -517,8 +521,9 @@ class SimpleCaptcha { /** * Hook for user login form submissions. - * @param User $u - * @param string $message + * @param $u User + * @param $pass + * @param $retval * @return bool true to continue, false to abort user creation */ function confirmUserLogin( $u, $pass, &$retval ) { @@ -558,12 +563,12 @@ class SimpleCaptcha { if ( defined( 'MW_API' ) ) { # API mode # Asking for captchas in the API is really silly - $error = wfMsg( 'captcha-disabledinapi' ); + $error = wfMessage( 'captcha-disabledinapi' )->text(); return false; } $this->trigger = "{$wgUser->getName()} sending email"; if ( !$this->passCaptcha() ) { - $error = wfMsg( 'captcha-sendemail-fail' ); + $error = wfMessage( 'captcha-sendemail-fail' )->text(); return false; } } @@ -586,7 +591,7 @@ class SimpleCaptcha { } /** - * @param $module ApiBae + * @param $module ApiBase * @param $desc array * @return bool */ @@ -678,7 +683,7 @@ class SimpleCaptcha { * @access private */ function loadText( $editPage, $section ) { - $rev = Revision::newFromTitle( $editPage->mTitle ); + $rev = Revision::newFromTitle( $editPage->mTitle, false, Revision::READ_LATEST ); if ( is_null( $rev ) ) { return ""; } else { @@ -694,7 +699,8 @@ class SimpleCaptcha { /** * Extract a list of all recognized HTTP links in the text. - * @param string $text + * @param $editpage EditPage + * @param $text string * @return array of strings */ function findLinks( &$editpage, $text ) { @@ -712,10 +718,10 @@ class SimpleCaptcha { */ function showHelp() { global $wgOut; - $wgOut->setPageTitle( wfMsg( 'captchahelp-title' ) ); - $wgOut->addWikiText( wfMsg( 'captchahelp-text' ) ); + $wgOut->setPageTitle( wfMessage( 'captchahelp-title' )->text() ); + $wgOut->addWikiMsg( 'captchahelp-text' ); if ( CaptchaStore::get()->cookiesNeeded() ) { - $wgOut->addWikiText( wfMsg( 'captchahelp-cookies-needed' ) ); + $wgOut->addWikiMsg( 'captchahelp-cookies-needed' ); } } } -- cgit v1.2.2