{"record":{"id":"76ce0b891fed10b4","repo":"Dolibarr/dolibarr","slug":"if-define-norequireuser-is-set-you-must-also-set","errorCode":null,"errorMessage":"If define NOREQUIREUSER is set, you must also set NOREQUIREMENU or not set it.","messagePattern":"If define NOREQUIREUSER is set, you must also set NOREQUIREMENU or not set it\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"htdocs/main.inc.php","lineNumber":66,"sourceCode":"if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) {\n\t[$usec, $sec] = explode(\" \", microtime());\n\t$micro_start_time = ((float) $usec + (float) $sec);\n\t// Add Xdebug code coverage\n\t//define('XDEBUGCOVERAGE',1);\n\tif (defined('XDEBUGCOVERAGE')) {\n\t\txdebug_start_code_coverage();\n\t}\n}\n\nrequire __DIR__.'/waf.inc.php';\n\n// Check consistency of NOREQUIREXXX DEFINES\nif ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && !defined('NOREQUIREMENU')) {\n\tprint 'If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not set them.';\n\texit;\n}\nif (defined('NOREQUIREUSER') && !defined('NOREQUIREMENU')) {\n\tprint 'If define NOREQUIREUSER is set, you must also set NOREQUIREMENU or not set it.';\n\texit;\n}\n\n// This is to make Dolibarr working with Plesk\nif (!empty($_SERVER['DOCUMENT_ROOT']) && substr($_SERVER['DOCUMENT_ROOT'], -6) !== 'htdocs') {\n\tset_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');\n}\n\n// Include the conf.php and functions.lib.php and security.lib.php. This defined the constants like DOL_DOCUMENT_ROOT, DOL_DATA_ROOT, DOL_URL_ROOT...\nrequire_once 'filefunc.inc.php';\n/**\n * @var Conf $conf\n * @var DoliDB $db\n * @var HookManager $hookmanager\n * @var Translate $langs\n * @var User $user\n *\n * @var ?string $php_session_save_handler","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/Dolibarr/dolibarr/blob/598aa4bdada683d17ca04b1842548821ff0eb6c6/htdocs/main.inc.php#L48-L84","documentation":"A second consistency check in main.inc.php: pages that define NOREQUIREUSER (skip loading the user object) must also define NOREQUIREMENU, because menu rendering depends on the loaded user. Without it Dolibarr prints this message and exits before doing any more work.","triggerScenarios":"An entry script calls define('NOREQUIREUSER', 1) then includes main.inc.php without define('NOREQUIREMENU', 1).","commonSituations":"Public pages (login, install, cron) that skip authentication but copied only part of the required define set; upgrade of Dolibarr adding the new guard to legacy pages.","solutions":["Add define('NOREQUIREMENU', 1) next to define('NOREQUIREUSER', 1)","Remove NOREQUIREUSER if your page needs the $user object anyway","Audit all custom entry points for define-set consistency after upgrading Dolibarr"],"exampleFix":"// before\ndefine('NOREQUIREUSER', 1);\nrequire '../main.inc.php';\n// after\ndefine('NOREQUIREUSER', 1);\ndefine('NOREQUIREMENU', 1);\nrequire '../main.inc.php';","handlingStrategy":"validation","validationCode":"if (defined('NOREQUIREUSER') && !defined('NOREQUIREMENU')) { define('NOREQUIREMENU', 1); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Whenever you skip user loading, always skip menu loading too","Copy complete define blocks from a recent Dolibarr skeleton page (e.g. public/demo pages)","Grep your custom pages for NOREQUIREUSER and verify NOREQUIREMENU is present"],"tags":["php","dolibarr","bootstrap","configuration"],"backgroundTag":"conflicting-config-options","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"}