Skip to content

Bugfix Issue 1557 isIssueTrackerEnabled NullResult EWarning

CI Agent edited this page Sep 21, 2026 · 1 revision

Bugfix — Issue #1557: PHP 8 E_WARNING in isIssueTrackerEnabled() when test project id does not exist

Problem

Every ASIDE init for a non-existent / stale test project id wrote an E_WARNING to the events table:

E_WARNING
Trying to access array offset on null - in .../lib/functions/testproject.class.php - Line 3487
source: GUI - Test Project ID : 1

HTTP stays 200 — the symptom only shows in the Event Viewer / events table (log_level 2, activity=PHP).

Reproduce at HEAD (fresh-import CI box, zero testprojects rows):

curl -b <cookies> "http://localhost:8082/api/aside/index.php?action=init&tproject_id=1&tplan_id=2"

→ HTTP 200 + one new E_WARNING row per call (events ids 2, 3 observed live).

Root Cause

  • lib/functions/database.class.php:785 get_recordset() inits $output = null; a 0-row SELECT returns null.
  • lib/functions/testproject.class.php:3479 isIssueTrackerEnabled($id) → $ret[0]['issue_tracker_enabled'] (line 3487) — offset access on null throws the PHP 8 warning.
  • Triggered whenever the referenced tproject_id has no row.
  • Blast radius: api/aside/index.php:125, lib/general/asideMenu.php:71, lib/results/resultsNavigator.php:126 — all consume the value only inside a boolean-AND report filter ((enabled=='bts') && $btsEnabled); no strict-type checks exist, so null and 0 are behaviourally identical.

Fix

Branch fix/issue-1557, commit 98d4d1f0b:

$ret = $this->db->get_recordset($sql);
if( !is_array($ret) || !isset($ret[0]['issue_tracker_enabled']) )
{
  return 0;
}
return $ret[0]['issue_tracker_enabled'];

Fail-closed 0 (= issue tracker disabled, the schema default) hides nothing beyond the BTS report affordances for a project that does not exist. Happy path untouched. Rejected: a displayInfo() unknown-project page (behaviour change beyond a log bug), changing get_recordset() to return [] (database-contract change, wide blast radius), unifying the sibling isCodeTrackerEnabled() (drive-by refactor).

Verification

  • R1 non-existent id 1 (events cleared first): 3× ASIDE init → HTTP 200 each, events count stays 0 (pre-fix: 1 E_WARNING per call).
  • R2 valid id 100 (issue_tracker_enabled=1 seeded): HTTP 200, full ASIDE JSON, events stays 0.
  • R3 php -l clean on all 4 touched-path PHP files.
  • R4 Event hygiene: zero Error/Warning rows after the matrix; Event Viewer clean:

Event Viewer clean after fix

Regression suite 1557 3/3 PASS in tmp/TLU_Test_Cases.md. No user-facing strings → no i18n changes.

Clone this wiki locally