Bugfix Issue 582 ResultsGeneral ForEachNull TprojOpt - sebiboga/testlink-upgraded GitHub Wiki
Issue 582 — resultsGeneral.php: foreach on null + tprojOpt mismatch (E_WARNINGs)
Issue: https://github.com/sebiboga/testlink-upgraded/issues/582
Fixed by: https://github.com/sebiboga/testlink-upgraded/issues/633 (commit 73d9c7c97)
Symptom
Viewing General Test Plan Metrics for a test plan without platforms generated 3 E_WARNINGs per page load:
foreach() argument must be of type array|object, null givenatlib/results/resultsGeneral.php:63Undefined property: stdClass::$tprojOpt+Attempt to read property "testPriorityEnabled" on nullfrom the compiled Dashio template (gui/templates/dashio/results/resultsGeneral.tpl, lines 179 and 247)
Root Cause
Two independent bugs:
-
Uninitialized
$items2loop—$items2loop[] = 'platform'was only assigned insideif($gui->showPlatforms), butforeach($items2loop)at line 63 ran unconditionally. WhenshowPlatforms=false,$items2loopwas undefined → PHP 8 E_WARNING. -
Template property name mismatch —
initializeGui()assigns$gui->testprojectOptions(lib/results/resultsGeneral.php:250-251), but the Dashio template read$gui->tprojOpt— a property that was never set. The tl-classic template used the correct name.
Fix (applied in commit 73d9c7c97, ref #633)
lib/results/resultsGeneral.php:50: added$items2loop = array();initialization before theshowPlatformsblockgui/templates/dashio/results/resultsGeneral.tpl:179,247: changed$gui->tprojOpt→$gui->testprojectOptions
Verification
- Load General Test Plan Metrics on plan without platforms → page loads cleanly
- Zero
resultsGeneral.phpE_WARNINGs in Event Viewer - No console errors
- Regression test cases in
tmp/TLU_Test_Cases.md(TC-582-01 through TC-582-03)