{"record":{"id":"6e25fe53f3c83c45","repo":"Dolibarr/dolibarr","slug":"error-the-captcha-handler-class-classname-was-not-found","errorCode":null,"errorMessage":"Error, the captcha handler class ${classname} was not found after the include","messagePattern":"Error, the captcha handler class (.+?) was not found after the include","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"htdocs/main.inc.php","lineNumber":659,"sourceCode":"\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\n\t\t\t\t$langs->loadLangs(array('main', 'errors'));\n\n\t\t\t\t$_SESSION[\"dol_loginmesg\"] = (empty($_SESSION[\"dol_loginmesg\"]) ? \"\" : $_SESSION[\"dol_loginmesg\"].\"<br>\\n\").$langs->transnoentitiesnoconv(\"ErrorBadValueForCode\");\n\t\t\t\t$test = false;\n","sourceCodeStart":641,"sourceCodeEnd":677,"githubUrl":"https://github.com/Dolibarr/dolibarr/blob/598aa4bdada683d17ca04b1842548821ff0eb6c6/htdocs/main.inc.php#L641-L677","documentation":"After including the captcha module file (modCaptcha<Name>.class.php), Dolibarr instantiates the class named $classname. If the include succeeded but the class still does not exist (filename/classname mismatch), login is refused with this message stored in $_SESSION['dol_loginmesg'].","triggerScenarios":"Captcha module file included but the class declared inside does not match the expected name (modCaptcha.ucfirst($captcha)); the included file is empty or declares a different class.","commonSituations":"Renaming a class inside a custom captcha module without renaming the file; truncated/partial file uploads leaving a class-less file; a stub placeholder file with no class.","solutions":["Open htdocs/core/modules/captcha/modCaptcha<Name>.class.php and confirm the declared class name matches the expected 'modCaptcha'.ucfirst($captcha).","Rename the file or class so they match, then retry login.","Re-upload/restore the module file if it was truncated.","Check the captcha selection value in setup: a typo there changes the expected class name."],"exampleFix":"// before: file modCaptchaRey.class.php\nclass modCaptchaReCaptcha extends ModeleCaptcha {}\n// after\nclass modCaptchaRey extends ModeleCaptcha {}","handlingStrategy":"validation","validationCode":"include_once $file;\nif (!class_exists('modCaptcha'.ucfirst($captcha))) { /* file/class mismatch */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Follow the modCaptcha<Name> file/class naming convention exactly","Lint module files after deployment (php -l)","Test captcha modules on staging before enabling in production"],"tags":["dolibarr","captcha","class-loading"],"backgroundTag":"class-not-found","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"}