Bugfix Issue 679 ResultsPlan Screens TestprojectOptions EWarning - sebiboga/testlink-upgraded GitHub Wiki
Issue 679 — E_WARNING "Undefined array key testprojectOptions" on results/plan screens
Issue: #679
Branch: fix/issue-679
Status: VERIFIED-FIXED (2026-08-25)
Symptom
Loading Free Test Cases (lib/results/freeTestCases.php) produced 2 PHP warnings per request
into the Event Viewer (events table, log_level=2):
E_WARNING Undefined array key "testprojectOptions" - in .../lib/results/freeTestCases.php - Line 25
E_WARNING Attempt to read property "testPriorityEnabled" on null - in .../lib/results/freeTestCases.php - Line 25
The same unguarded session key read existed in two more screens (confirmed by static analysis):
lib/results/tcNotRunAnyPlatform.php:116,216,228lib/plan/tc_exec_assignment.php:222gui/templates/dashio/plan/tc_exec_assignment.tpl:175,221,229
Root cause
$_SESSION['testprojectOptions'] is never written anywhere in this codebase. Every unguarded
read throws Undefined array key followed by Attempt to read property on null. The priority-gated
UI blocks can never activate because the condition can never be true.
This is the same root cause as #495 (the
mainPage.php variant), which was fixed by switching to testproject::getOptions($tproject_id).
Fix
Replaced all unguarded $_SESSION['testprojectOptions']->testPriorityEnabled reads with live DB
lookups via testproject::getOptions($tproject_id)->testPriorityEnabled, guarded by isset():
lib/results/freeTestCases.php:25—$tproject_mgr->getOptions($args->tproject_id)(mgr already existed)lib/results/tcNotRunAnyPlatform.php:116— same pattern in global scopelib/results/tcNotRunAnyPlatform.php buildMatrix()— added$tproject_idparameter, creates its owntestproject($db)instancelib/plan/tc_exec_assignment.php:222— newtestproject($db)instance; stores result in$gui->testPriorityEnabledgui/templates/dashio/plan/tc_exec_assignment.tpl:175,221,229— changed$session['testprojectOptions']->testPriorityEnabledto$gui->testPriorityEnabled
Remaining $_SESSION['testprojectOptions'] reads in printDocOptions.php:156 and
resultsNavigator.php:100 are already guarded with isset() and never warn — left as-is.
Files changed
lib/results/freeTestCases.phplib/results/tcNotRunAnyPlatform.phplib/plan/tc_exec_assignment.phpgui/templates/dashio/plan/tc_exec_assignment.tpl
Verification
- PHP syntax check: all files pass
php -l freeTestCases.phppage load: 0 new E_WARNING eventstcNotRunAnyPlatform.phppage load: 0 new E_WARNING eventstc_exec_assignment.phppage load: 0 new E_WARNING eventsSELECT description FROM events WHERE description LIKE '%testprojectOptions%'→ 0 rows
Regression suite: tmp/TLU_Test_Cases.md → Suite 679 — 4/4 PASS.