{"record":{"id":"948380f1f7449289","repo":"Dolibarr/dolibarr","slug":"error-the-captcha-handler-class-does-not-have-any-method","errorCode":null,"errorMessage":"Error, the captcha handler ${class} does not have any method validateCodeAfterLoginSubmit()","messagePattern":"Error, the captcha handler (.+?) does not have any method validateCodeAfterLoginSubmit\\(\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"htdocs/main.inc.php","lineNumber":654,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\n\t\t\t// The file for captcha check has been found\n\t\t\tif ($fullpathclassfile) {\n\t\t\t\tinclude_once $fullpathclassfile;\n\t\t\t\t$captchaobj = null;\n\n\t\t\t\t// Charging the numbering class\n\t\t\t\t$classname = \"modCaptcha\".ucfirst($captcha);\n\t\t\t\tif (class_exists($classname)) {\n\t\t\t\t\t/** @var ModeleCaptcha $captchaobj */\n\t\t\t\t\t$captchaobj = new $classname($db, $conf, $langs, $user);\n\t\t\t\t\t'@phan-var-force ModeleCaptcha $captchaobj';\n\n\t\t\t\t\tif (is_object($captchaobj) && method_exists($captchaobj, 'validateCodeAfterLoginSubmit')) {\n\t\t\t\t\t\t$ok = $captchaobj->validateCodeAfterLoginSubmit(); // @phan-suppress-current-line PhanUndeclaredMethod\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$_SESSION[\"dol_loginmesg\"] =  'Error, the captcha handler '.get_class($captchaobj).' does not have any method validateCodeAfterLoginSubmit()';\n\t\t\t\t\t\t$test = false;\n\t\t\t\t\t\t$error++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t$_SESSION[\"dol_loginmesg\"] =  'Error, the captcha handler class '.$classname.' was not found after the include';\n\t\t\t\t\t$test = false;\n\t\t\t\t\t$error++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t$_SESSION[\"dol_loginmesg\"] = 'Error, the captcha handler '.$captcha.' has no class file found modCaptcha'.ucfirst($captcha);\n\t\t\t\t$test = false;\n\t\t\t\t$error++;\n\t\t\t}\n\n\t\t\t// Process error of captcha validation\n\t\t\tif (!$ok) {\n\t\t\t\tdol_syslog('--- Security warning: Bad value for code, connection refused', LOG_NOTICE);\n\t\t\t\t// Load translation files required by page","sourceCodeStart":636,"sourceCodeEnd":672,"githubUrl":"https://github.com/Dolibarr/dolibarr/blob/598aa4bdada683d17ca04b1842548821ff0eb6c6/htdocs/main.inc.php#L636-L672","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nclass modCaptchaMy extends ModeleCaptcha { /* no validateCodeAfterLoginSubmit */ }\n// after\nclass modCaptchaMy extends ModeleCaptcha {\n    public function validateCodeAfterLoginSubmit() {\n        return $this->verifyCode(GETPOST('captcha_code', 'alpha'));\n    }\n}","handlingStrategy":"validation","validationCode":"$ref = new ReflectionClass($classname);\nif (!$ref->hasMethod('validateCodeAfterLoginSubmit')) { /* fix module before enabling */ }","typeGuard":"function isValidCaptchaHandler($obj) { return $obj instanceof ModeleCaptcha && method_exists($obj, 'validateCodeAfterLoginSubmit'); }","tryCatchPattern":null,"preventionTips":["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"],"tags":["dolibarr","captcha","api-change"],"backgroundTag":"method-not-implemented","analyzedSha":"598aa4bdada683d17ca04b1842548821ff0eb6c6","analyzedAt":"2026-09-14T11:12:15.309Z","contentChangedAt":"2026-09-14T11:12:15.309Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}