I want users to provide a token when registering as well as pass FancyCaptcha. I've written an extension based on ConfirmEdit to populate the signup form with a token field and test the input.
ConfirmEdit injectUserCreate() calls $template->set( 'header', ... ) and I do too (there's a note in ConfirmEdit.php that this may cause problems, so I workaround this by requiring my extension after ConfirmEdit in LocalSettings.php (which causes mine to be called after) and append to the current $template->data['header'] value in my injectUserCreate(). So far so good, form displays correctly.
A minimal extension which does the above and reproduces the problem below is at http://gondwanaland.com/tmp/ConfirmTest/ConfirmTest.php.txt
Works fine when the captcha value entered is incorrect or both values are incorrect.
However, when I enter a correct captcha value (NB same behavior with FancyCaptcha or SimpleCaptcha) and an incorrect token I get an error. The array below is dumped (looks like from line 84 of Hooks.php in current svn) and the stacktrace well below is printed out.
It looks like the hooks that should be associated with ConfirmEdit are now null, causing the error. I don't see where in wfRunHooks() or its invoker hooks are nulled once run successfully. Am I missing something obvious?
I'll probably just maintain a hacked version of FancyCaptcha that also incorporates my token test, but I'd rather not, and I'd like to understand what is going on in any case...
Thanks in advance for any hints!
Output of var_dump( $wgHooks ) seen upon error:
array(3) { ["EditFilter"]=> array(1) { [0]=> array(2) { [0]=> &NULL [1]=> string(11) "confirmEdit" } } ["UserCreateForm"]=>
array(2) { [0]=> array(2) { [0]=> &NULL [1]=> string(16) "injectUserCreate" } [1]=> array(2) { [0]=> &object(ConfirmTest)#19 (1) { ["trigger"]=>
string(11) "new account" } [1]=> string(16) "injectUserCreate" } } ["AbortNewAccount"]=> array(2) { [0]=> array(2) { [0]=> &NULL [1]=> string(17) "confirmUserCreate" } [1]=>
array(2) { [0]=> &object(ConfirmTest)#19 (1) { ["trigger"]=> string(11) "new account" } [1]=> string(17) "confirmUserCreate" } } }
Stacktrace printed upon error:
Unknown datatype in hooks for UserCreateForm
Backtrace:
#0 /var/www/w0/includes/SpecialUserlogin.php(582): wfRunHooks('UserCreateForm', Array) #1 /var/www/w0/includes/SpecialUserlogin.php(266): LoginForm->mainLoginForm('You did not ent...') #2 /var/www/w0/includes/SpecialUserlogin.php(141): LoginForm->addNewAccountInternal() #3 /var/www/w0/includes/SpecialUserlogin.php(86): LoginForm->addNewAccount() #4 /var/www/w0/includes/SpecialUserlogin.php(19): LoginForm->execute() #5 /var/www/w0/includes/SpecialPage.php(499): wfSpecialUserlogin(NULL, Object(SpecialPage)) #6 /var/www/w0/includes/SpecialPage.php(368): SpecialPage->execute(NULL) #7 /var/www/w0/includes/Wiki.php(156): SpecialPage::executePath(Object(Title)) #8 /var/www/w0/includes/Wiki.php(47): MediaWiki->initializeSpecialCases(Object(Title), Object(OutputPage), Object(WebRequest)) #9 /var/www/w0/index.php(47): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest)) #10 {main}
Relevant portion of LocalSettings.php:
require_once( "$IP/extensions/ConfirmEdit/ConfirmEdit.php" ); require_once( "$IP/extensions/ConfirmTest/ConfirmTest.php" );