Problems with module_invoke due to changes in PHP 3.3 call by reference.
I've been working on a site built in Drupal 6. The site is to integrate with an existing system and therefore I had to integrate into an existing login authentication mechanism. The components are:
- Existing front-end login/logout mechanism, written in PHP.
- Existing back-end scripts, written in Perl.
- New back-end areas, written in Drupal, ultimately in PHP.
I have therefore written my own authentication module based on the code example at this web site and also from the book Pro Drupal Development 2nd Edition.
Amongst other things, I had my own login validation function, along the lines of:
function mymodule_login_validate( $form, &$form_state )
{
$username = $form_state['values']['name'];
// next function checks whether the user exists in the existing 3rd party database
if ( externalUserExists( $username )) {
// If they do, we authenticate against them
if ( externalUserValidPassword( $username, $form_state['values']['pass'] )) {
user_external_login_register( $username, 'mymodule' );
user_authenticate_finalize( $form_state['values'] );
}
// else drop through to the end and return nothing
// Drupal will handle the rejection for us
} else {
// there's no user in the 3rd party database,
// so we authenticate against the Drupal DB: this gives us the ability
// to continue to have admin users
user_login_authenticate_validate( $form, &$form_state );
}
}It was all working well on my Debian 5 Lenny server, until I upgraded the server to Debian 6 Squeeze: at this point the login just stopped working, it just didn't happen!
module_invoke('mymodule','login_validate', null, &$formFields);
function module_invoke() {
$args = func_get_args();
$module = $args[0];
$hook = $args[1];
unset($args[0], $args[1]);
$function = $module . '_' . $hook;
if (module_hook($module, $hook)) {
return call_user_func_array($function, $args);
}
}
$result = call_user_func_array($function, $args);
if ( ($module == 'mymodule') && (!$result) ) {
$result = mymodule_login_validate(null, $args[3]);
}
return $result;mymodule_login_validate(null, &$formFields);
