Skip to content

Hook ReCaptcha::confirmEdit failed to return a value

Today, editing (and saving) a MediaWiki article barfed with:
Detected bug in an extension! Hook ReCaptcha::confirmEdit failed to return a value;
should return true to continue hook processing or false to abort.

Backtrace:

#0 ../includes/EditPage.php(802): wfRunHooks('EditFilter', Array)
#1 ../includes/EditPage.php(2552): EditPage->internalAttemptSave(false, false)
#2 ../includes/EditPage.php(389): EditPage->attemptSave()
#3 ../includes/EditPage.php(271): EditPage->edit()
#4 ../includes/Wiki.php(553): EditPage->submit()
#5 ../includes/Wiki.php(70): MediaWiki->performAction(Object(OutputPage),
     Object(Article), Object(Title), Object(User), Object(WebRequest))
#6 ../index.php(117): MediaWiki->performRequestForTitle(Object(Title), 
     Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
#7 {main}
Apparently, this has been caused by the recent upgrade to Debian/Squeeze, which comes with php-5.3.3. The fix is to apply the following patch to the reCAPTCHA extension:
--- mediawiki/ConfirmEdit.php.orig      2011-02-13 07:55:38.366172048 +0100
+++ mediawiki/ConfirmEdit.php   2011-02-13 07:59:47.115119111 +0100
@@ -483,7 +483,7 @@ class SimpleCaptcha {
         * @param string $section
         * @param bool true to continue saving, false to abort and show a captcha form
         */
-       function confirmEdit( &$editPage, $newtext, $section ) {
+       function confirmEdit( $editPage, $newtext, $section ) {
                if( $this->shouldCheck( $editPage, $newtext, $section ) ) {
                        if( $this->passCaptcha() ) {
                                return true;
--- mediawiki/ReCaptcha.php.orig        2011-02-13 07:57:27.700624763 +0100
+++ mediawiki/ReCaptcha.php     2011-02-13 08:05:47.903120256 +0100
@@ -97,7 +97,7 @@ class ReCaptcha extends SimpleCaptcha {
          * Called on all edit page saves. (EditFilter events)
          * @return boolean - true if page save should continue, false if should display Captcha widget.
          */
-        function confirmEdit( &$editPage, $newtext, $section ) {
+       function confirmEdit( $editPage, $newtext, $section ) {
                 if( $this->shouldCheck( $editPage, $newtext, $section ) ) {
 
                         if (!isset($_POST['recaptcha_response_field'])) {

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Smonff on :

This is very usefull, thank you very much for this patch.

C on :

@Smonff: fyi, this extension has been replaced with ConfirmEdit, http://www.mediawiki.org/wiki/Extension:ConfirmEdit

Ethan on :

I dont understand, so I add that code to what file exactly? e.g: LocalSettings.php?

Christian on :

See the diff: both ConfirmEdit.php and ReCaptcha.php within the ReCaptcha directory need to be patched. But please mind my last comment, you should switch to the ConfirmEdit extension. I haven't used the ReCaptcha extension in a while so I don't know if the fix is still necessary/sufficient.

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
Form options

Submitted comments will be subject to moderation before being displayed.