Dolibarr/dolibarr · error

If define NOREQUIREDB or NOREQUIRETRAN are set, you must…

Error message

If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not set them.

What it means

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.

Solutions

  1. Add define('NOREQUIREMENU', 1) alongside NOREQUIREDB/NOREQUIRETRAN before including main.inc.php
  2. Or remove the NOREQUIREDB/NOREQUIRETRAN defines if your page actually needs database or translation features
  3. Verify with defined() checks in your bootstrap that the define set is one of the allowed combinations

Example fix

// before
define('NOREQUIREDB', 1);
define('NOREQUIRETRAN', 1);
require '../main.inc.php';
// after
define('NOREQUIREDB', 1);
define('NOREQUIRETRAN', 1);
define('NOREQUIREMENU', 1);
require '../main.inc.php';
Defensive patterns

Strategy: validation

Validate before calling

if ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && !defined('NOREQUIREMENU')) { define('NOREQUIREMENU', 1); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of Dolibarr/dolibarr@598aa4bdad (2026-09-14). Data as JSON: /api/errors/2e4fdb7307580ac7. Report an issue: GitHub.

Appendix: source

Thrown at htdocs/main.inc.php:62

//@ini_set('memory_limit', '128M');	// This may be useless if memory is hard limited by your PHP

// For optional tuning. Enabled if environment variable MAIN_SHOW_TUNING_INFO is defined.
$micro_start_time = 0;	// Used as global var into printCommonFooter()
if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) {
	[$usec, $sec] = explode(" ", microtime());
	$micro_start_time = ((float) $usec + (float) $sec);
	// Add Xdebug code coverage
	//define('XDEBUGCOVERAGE',1);
	if (defined('XDEBUGCOVERAGE')) {
		xdebug_start_code_coverage();
	}
}

require __DIR__.'/waf.inc.php';

// Check consistency of NOREQUIREXXX DEFINES
if ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && !defined('NOREQUIREMENU')) {
	print 'If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not set them.';
	exit;
}
if (defined('NOREQUIREUSER') && !defined('NOREQUIREMENU')) {
	print 'If define NOREQUIREUSER is set, you must also set NOREQUIREMENU or not set it.';
	exit;
}

// This is to make Dolibarr working with Plesk
if (!empty($_SERVER['DOCUMENT_ROOT']) && substr($_SERVER['DOCUMENT_ROOT'], -6) !== 'htdocs') {
	set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
}

// 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...
require_once 'filefunc.inc.php';
/**
 * @var Conf $conf
 * @var DoliDB $db
 * @var HookManager $hookmanager

View on GitHub (pinned to 598aa4bdad)