{"record":{"id":"2e4fdb7307580ac7","repo":"Dolibarr/dolibarr","slug":"if-define-norequiredb-or-norequiretran-are-set-you-must-also","errorCode":null,"errorMessage":"If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not set them.","messagePattern":"If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not set them\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"htdocs/main.inc.php","lineNumber":62,"sourceCode":"//@ini_set('memory_limit', '128M');\t// This may be useless if memory is hard limited by your PHP\n\n// For optional tuning. Enabled if environment variable MAIN_SHOW_TUNING_INFO is defined.\n$micro_start_time = 0;\t// Used as global var into printCommonFooter()\nif (!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","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/Dolibarr/dolibarr/blob/598aa4bdada683d17ca04b1842548821ff0eb6c6/htdocs/main.inc.php#L44-L80","documentation":"This consistency check in main.inc.php refuses to boot a page when NOREQUIREDB or NOREQUIRETRAN is defined without NOREQUIREMENU. Those defines skip database/translation loading, but the menu system still needs them, so Dolibarr blocks the inconsistent combination early to avoid a fatal error later during menu generation.","triggerScenarios":"A custom PHP entry script or REST-ish endpoint defines('NOREQUIREDB') or ('NOREQUIRETRAN') to skip DB/translation loading but forgets to also define('NOREQUIREMENU'), then calls require main.inc.php.","commonSituations":"Writing a lightweight AJAX/JSON endpoint modeled on an older skeleton; copying a page header from Dolibarr 3.x where the check did not exist; refactoring main.inc.php includes and leaving stale defines.","solutions":["Add define('NOREQUIREMENU', 1) alongside NOREQUIREDB/NOREQUIRETRAN before including main.inc.php","Or remove the NOREQUIREDB/NOREQUIRETRAN defines if your page actually needs database or translation features","Verify with defined() checks in your bootstrap that the define set is one of the allowed combinations"],"exampleFix":"// before\ndefine('NOREQUIREDB', 1);\ndefine('NOREQUIRETRAN', 1);\nrequire '../main.inc.php';\n// after\ndefine('NOREQUIREDB', 1);\ndefine('NOREQUIRETRAN', 1);\ndefine('NOREQUIREMENU', 1);\nrequire '../main.inc.php';","handlingStrategy":"validation","validationCode":"if ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && !defined('NOREQUIREMENU')) { define('NOREQUIREMENU', 1); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize the define set in a shared bootstrap helper for custom pages","Keep NOREQUIREMENU together with NOREQUIREDB/NOREQUIRETRAN/NOREQUIREUSER whenever used","Test each custom entry point after Dolibarr upgrades"],"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"}