Dolibarr/dolibarr · error
Error, the captcha handler
Error message
Error, the captcha handler ${class} does not have any method validateCodeAfterLoginSubmit() What it means
Dolibarr dynamically loads a captcha handler class during login submit and calls validateCodeAfterLoginSubmit() on it. When the instantiated object does not implement that method, the session message records the missing-method error, $test becomes false and login is refused. This protects against broken or partial custom captcha module implementations.
Solutions
- Check which captcha module is enabled (Setup > Security) and inspect its class file for validateCodeAfterLoginSubmit().
- Update or fix the captcha module class to implement validateCodeAfterLoginSubmit() per the ModeleCaptcha contract.
- Temporarily switch to the built-in captcha module to restore logins.
- Confirm the loaded class is the expected one by debugging get_class($captchaobj).
Example fix
// before
class modCaptchaMy extends ModeleCaptcha { /* no validateCodeAfterLoginSubmit */ }
// after
class modCaptchaMy extends ModeleCaptcha {
public function validateCodeAfterLoginSubmit() {
return $this->verifyCode(GETPOST('captcha_code', 'alpha'));
}
} Defensive patterns
Strategy: validation
Validate before calling
$ref = new ReflectionClass($classname);
if (!$ref->hasMethod('validateCodeAfterLoginSubmit')) { /* fix module before enabling */ } Type guard
function isValidCaptchaHandler($obj) { return $obj instanceof ModeleCaptcha && method_exists($obj, 'validateCodeAfterLoginSubmit'); } Prevention
- Test custom captcha modules against a dev login before production
- Always extend ModeleCaptcha and implement all abstract methods
- Pin module versions compatible with your Dolibarr release
When it happens
Trigger: The captcha option selects a custom captcha module whose class was instantiated but does not extend ModeleCaptcha or omits validateCodeAfterLoginSubmit(), e.g. after an API change in a custom modCaptcha*.class.php.
Common situations: Custom captcha modules written for an older Dolibarr API lacking the newer validateCodeAfterLoginSubmit method; partially copied module files; third-party captcha modules not updated after a Dolibarr version bump.
Related errors
- Error, the captcha handler class
- Error, the captcha handler
- ErrorBadValueForCode
- If define NOREQUIREDB or NOREQUIRETRAN are set, you must…
- If define NOREQUIREUSER is set, you must also set…
AI-assisted analysis of Dolibarr/dolibarr@598aa4bdad (2026-09-14).
Data as JSON: /api/errors/948380f1f7449289.
Report an issue: GitHub.
Appendix: source
Thrown at htdocs/main.inc.php:654
}
}
// The file for captcha check has been found
if ($fullpathclassfile) {
include_once $fullpathclassfile;
$captchaobj = null;
// Charging the numbering class
$classname = "modCaptcha".ucfirst($captcha);
if (class_exists($classname)) {
/** @var ModeleCaptcha $captchaobj */
$captchaobj = new $classname($db, $conf, $langs, $user);
'@phan-var-force ModeleCaptcha $captchaobj';
if (is_object($captchaobj) && method_exists($captchaobj, 'validateCodeAfterLoginSubmit')) {
$ok = $captchaobj->validateCodeAfterLoginSubmit(); // @phan-suppress-current-line PhanUndeclaredMethod
} else {
$_SESSION["dol_loginmesg"] = 'Error, the captcha handler '.get_class($captchaobj).' does not have any method validateCodeAfterLoginSubmit()';
$test = false;
$error++;
}
} else {
$_SESSION["dol_loginmesg"] = 'Error, the captcha handler class '.$classname.' was not found after the include';
$test = false;
$error++;
}
} else {
$_SESSION["dol_loginmesg"] = 'Error, the captcha handler '.$captcha.' has no class file found modCaptcha'.ucfirst($captcha);
$test = false;
$error++;
}
// Process error of captcha validation
if (!$ok) {
dol_syslog('--- Security warning: Bad value for code, connection refused', LOG_NOTICE);
// Load translation files required by pageView on GitHub (pinned to 598aa4bdad)