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
[Technical Debt]: Handle query() returning false in CI4 migration #3634
As of CI 4.1.2 query() returns false when a query fails. We may need to go through the code and add a check on the return value. Formerly I believe it returned an empty object. This function is used extensively in the models, so we need to think this one through.
changed the title [-]CI4: query() now returns false for failed queries[/-][+][Technical Debt]: Handle query() returning false in CI4 migration[/+]on Apr 1, 2026
#!/bin/bashset -euo pipefail
gh api repos/opensourcepos/opensourcepos/commits/master --jq '.sha'
python - <<'PY'import jsonwith open('composer.json') as f: data=json.load(f)print("CodeIgniter requirement:", data.get('require',{}).get('codeigniter4/framework'))with open('composer.lock') as f: data=json.load(f)for package in data.get('packages',[]): if package['name']=='codeigniter4/framework': print("CodeIgniter locked version:",package['version'])PY
ast-grep outline app/Models/Tax.php --items all
ast-grep outline app/Models/Sale.php --match 'get_all_suspended' --items all
ast-grep outline app/Models/Reports/Inventory_low.php --items all
ast-grep outline app/Config/Database.php --items all
sed -n '80,140p' app/Models/Tax.php
sed -n '1180,1210p' app/Models/Sale.php
sed -n '1,95p' app/Models/Reports/Inventory_low.php
sed -n '15,46p' app/Config/Database.php
rg -n -C2 --glob '*.php' -- 'DBDebug\s*=|DBDebug.*=>|transException\s*\(' app
Length of output: 10441
@jekkos Yes. This remains an issue on current master (1b8ee2e3).
The project uses CodeIgniter 4.7.4. A failed query() can still return false when DBDebug is disabled. The default database configuration disables DBDebug in production.
Several methods still call getResultArray() without checking for false:
The ?: [] fallback does not protect these calls. PHP calls getResultArray() first, which fails if $query is false.
I recommend keeping #3634 open. Failed queries need explicit error handling before result access. For tax calculations, a database failure should not silently become an empty tax list.
This conclusion comes from code inspection. I did not run database-failure tests.
Activity
This is intended to start resolving opensourcepos#3634. CIR4 query() …
This is intended to start resolving #3634. CIR4 query() now returns f…
This is intended to start resolving #3634. CIR4 query() now returns f…
This is intended to start resolving #3634. CIR4 query() now returns f…
This is intended to start resolving #3634. CIR4 query() now returns f…
This is intended to start resolving #3634. CIR4 query() now returns f…
This is intended to start resolving #3634. CIR4 query() now returns f…
[-]CI4: query() now returns false for failed queries[/-][+][Technical Debt]: Handle query() returning false in CI4 migration[/+]jekkos commentedon Oct 2, 2026
@CodeRabbit is this still an issue?
coderabbitai commentedon Oct 2, 2026
🧩 Analysis chain
🏁 Script executed:
Length of output: 1401
🏁 Script executed:
Length of output: 21622
🤖 web_search executed:
CodeIgniter 4 BaseConnection query returns false DBDebug exceptions 4.1.2 upgrade query return values current documentationLength of output: 1185
🏁 Script executed:
Length of output: 10441
@jekkosYes. This remains an issue on currentmaster(1b8ee2e3).The project uses CodeIgniter 4.7.4. A failed
query()can still returnfalsewhenDBDebugis disabled. The default database configuration disablesDBDebugin production.Several methods still call
getResultArray()without checking forfalse:Tax::get_taxes()Sale::get_all_suspended()Inventory_low::getData()The
?: []fallback does not protect these calls. PHP callsgetResultArray()first, which fails if$queryisfalse.I recommend keeping
#3634open. Failed queries need explicit error handling before result access. For tax calculations, a database failure should not silently become an empty tax list.This conclusion comes from code inspection. I did not run database-failure tests.
You are interacting with an AI system.
fix(models): handle query() returning false in result-consuming methods
fix(models): handle query() returning false in result-consuming metho…
feat(reports,config,docs): Merge from master. add detailed item sales…