You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Fix crash (Undefined variable $allowed_modules) when employee only has office modules assigned #4681
A crash occurs with ErrorException: Undefined variable $allowed_modules in app/Views/partial/header.php on line 143 when a logged-in employee has no modules assigned for the Main Home/Inicio dashboard, but does have permissions for back-office modules under the office section.
📋 Steps to Reproduce
Create or modify an employee's permissions.
Uncheck all standard/home modules (like Sales, Items, Customers) but leave administrative/office modules checked (like Permissions, Store Config).
Log in with this employee account.
The application automatically redirects to /home and crashes because $allowed_modules is never populated or passed to the header view by the controller.
✅ Expected Behavior
Instead of a hard crash due to an uninitialized array variable, the system should handle this permission structure gracefully.
Proposed Elegant Solution
A patch shouldn't just hide the error in the view using an isset() check. Instead, the logical core routing in the controller (likely Home.php) should check if the array is empty.
If the employee has no default home modules but holds at least one active backend permission, the system should automatically inject or fallback to the office module link in the main navigation header. This ensures the user lands on a coherent interface tailored to their back-office role.
Hi, I’d like to work on this issue if it’s still available.
I’ve reviewed the issue and would like to investigate the root cause of the Undefined variable $allowed_modules error, then submit a PR with a proper fix and tests.
Status: Still present (not yet merged into master).
Evidence:
app/Controllers/Secure_Controller.php builds $this->global_view_data['allowed_modules'] only inside the loop foreach ($allowed_modules->getResult() as $module) { $this->global_view_data['allowed_modules'][] = $module; }. When an employee has zero allowed modules for the active menu_group (e.g. no Home modules but some Office modules, landing on the Home menu group), that loop never executes and the allowed_modules key is never set in global_view_data.
app/Views/partial/header.php declares @var array $allowed_modules and does foreach ($allowed_modules as $module) unconditionally — with no isset()/?? guard — which is exactly the Undefined variable $allowed_modules crash described.
Activity
SathwikReddyB commentedon Oct 6, 2026
Hi, I’d like to work on this issue if it’s still available.
I’ve reviewed the issue and would like to investigate the root cause of the
Undefined variable $allowed_moduleserror, then submit a PR with a proper fix and tests.Would it be okay for me to take this issue?
jekkos commentedon Oct 6, 2026
Sure go ahead any help is welcomed
objecttothis commentedon Oct 22, 2026
Claude Issue Checker Agent (cc @objecttothis)
I investigated this against current
master.Status: Still present (not yet merged into master).
Evidence:
app/Controllers/Secure_Controller.phpbuilds$this->global_view_data['allowed_modules']only inside the loopforeach ($allowed_modules->getResult() as $module) { $this->global_view_data['allowed_modules'][] = $module; }. When an employee has zero allowed modules for the activemenu_group(e.g. no Home modules but some Office modules, landing on the Home menu group), that loop never executes and theallowed_moduleskey is never set inglobal_view_data.app/Views/partial/header.phpdeclares@var array $allowed_modulesand doesforeach ($allowed_modules as $module)unconditionally — with noisset()/??guard — which is exactly theUndefined variable $allowed_modulescrash described.allowed_modulesand adds an Office-link fallback plus a regression test inHomeTest.php. It has not been merged as of this check (state: open).Since #4744 hasn't landed on
masteryet, the crash described in this issue is still reproducible there.Fix home navigation for office-only employees (#4681) (#4744)