[Bug]: Fix crash (Undefined variable $allowed_modules) when employee only has office modules assigned
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
Direzione di ricerca
Start by reading app/Views/partial/header.php around line 143 and tracing how the home controller, likely Home.php, supplies $allowed_modules. Reproduce with an employee who has only office permissions, then check the routing and navigation behavior for that permission set. Done means the employee reaches a coherent interface without the undefined-variable crash, with appropriate office navigation.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🐛 Bug Description
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
/homeand crashes because$allowed_modulesis 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.
📦 OpenSourcePOS Version
OpenSourcePOS 3.4.1
🔧 PHP Version
PHP 8.4
🌐 Browser(s)
Chrome
🖥️ Server Operating System
ubuntu 26.4
🗄️ Database
MySql 8
🌍 Web Server
apache 2.4
📊 System Information Report
Información de la Instalación OSPOS: 3.4.1 - 5f395d
Language Code: es-ES
Extensions & Modules:
» GD: Enabled ✓
» BC Math: Enabled ✓
» INTL: Enabled ✓
» OpenSSL: Enabled ✓
» MBString: Enabled ✓
» Curl: Enabled ✓
» Json: Enabled ✓
» Xml: Enabled ✓
User Configuration:
Browser: Chrome 151.0.0.0
Server Software: Apache/2.4.66 (Ubuntu)
PHP Version: 8.5.4
DB Version: 8.4.11-0ubuntu0.26.04.1
Server Port: 80
OS: Linux 7.0.0-1017-raspi
File Permissions:
» [writeable/logs:] - 0750 | Writable ✓ | Security Check Passed ✓
» [writable/uploads:] - 0755 | Writable ✓ | Vulnerable or Incorrect Permissions ✗
» [writable/uploads/item_pics:] - 0755 | Writable ✓ | Vulnerable or Incorrect Permissions ✗
» [importCustomers.csv:] - 0640 | Readable ✓ | Security Check Passed ✓
📜 Relevant Log Output
📸 Screenshots
No response
✓ Confirmation
- I certify that this is an unmodified copy of OpenSourcePOS
- I have searched existing issues to ensure this bug has not already been reported
- I have provided all the information requested above
- Lingua principale
- PHP
- Stelle
- 4.4k
- Fork
- 2.6k
- Merge medio
- 3g 2h
- PR unite (30g)
- 29
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di opensourcepos/opensourcepos
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
opensourcepos/opensourcepos#4743 ·
I maintainer di solito rispondono entro 2 giorni
-
Config\OSPOS::getDefaultSettings() fallback missing invoice_enable/work_order_enable causes ErrorException in Reports::get_sale_type_options()Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
opensourcepos/opensourcepos#4665 ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement needs owner question
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
opensourcepos/opensourcepos#3565 · 5 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 58/100
opensourcepos/opensourcepos#4754 ·
I maintainer di solito rispondono entro 2 giorni
-
Error 500 on fresh InstallAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
opensourcepos/opensourcepos#4746 · 9 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di opensourcepos/opensourcepos
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Automattic/blocks-engine#3090 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
macOS
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
beyondcode/herd-community#1771 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
-
module: user interface priority: high severity: minor type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno