Bugfix Issue 622 PlanView Tpl EWarning Spam - sebiboga/testlink-upgraded GitHub Wiki
Bugfix โ Issue #622: planView.tpl E_WARNING spam on Test Plan Management screens
Issue: #622
Branch: fix/issue-622-plan-warnings ยท Commits: a3fc7d8d9 (fix), 437024b54 (regression suite)
Status: FIXED & VERIFIED (2026-08-29)
Symptom
Every load of the Test Plan Management screen (lib/plan/planEdit.php?tproject_id=<n>,
default do_action=list, which renders gui/templates/dashio/plan/planView.tpl) emitted
four E_WARNING (level-2) events per rendered plan row into the events table:
Undefined array key "tcase_qty" ... *_0.file.planView.tpl.php:213
Undefined array key "build_qty" ... *_0.file.planView.tpl.php:217
Undefined array key "rights" ... *_0.file.planView.tpl.php:279
Trying to access array offset on null ... *_0.file.planView.tpl.php:279
Reproduced against a fresh DB: created test project B421:Bug421 Project (id=1) and test
plan Billable Resources (id=2) via the UI, then loaded planEdit.php?tproject_id=1 โ
events #9โ#12 were exactly the four lines above.
Root cause chain
lib/plan/planEdit.phpis the Test Plan Management screen. Itsdo_actionswitch ("list" default) sets the template toplan/planView.tpl(planEdit.php:210) and enriches the$gui->tplansrows withtcase_qty,build_qtyand per-planrights(planEdit.php:230-265).- But immediately after the switch,
$gui = initializeGui(...)replaces the object (planEdit.php:282). The fresh$gui->tplansis rebuilt as a plaingetAccessibleTestPlans()fetch (planEdit.php:470-474) โ no enrichment. - The template is then rendered via
planViewGUIInit()(lib/plan/planViewUtils.php:22-35), which only computesdrawPlatformQtyColumnand re-fetches the same plain rows โ it never adds the aggregates the template reads atplanView.tpl:129/132/171. plan/tpl/js/planView.jsrenders the DataTable from those keys; the compiled template (gui/templates_c/..._0.file.planView.tpl.php) accesses them unconditionally at lines 213/217/279 โ the four warnings.
The standalone lib/plan/planView.php was clean because its controller enriches the rows
inline before initializeGui() (lib/plan/planView.php:94-130); planEdit.php's flow
skips that inline path. (Historic side-note: the layout/cellContent/cellLabel
warnings mentioned in the report were already fixed by commit 6f66ffb4e; only the
planView.tpl-through-planEdit.php path was still broken.)
Approach โ enrich in planViewGUIInit
The fix moves the row-enrichment so it always survives planEdit.php's initializeGui()
re-init, mirroring lib/plan/planView.php:94-130:
lib/plan/planViewUtils.php โ planViewGUIInit() now, when $guiObj->tplans is non-empty:
- computes
tcase_qtyper plan via$tplanMgr->count_testcases($tplanSet, null, array('output' => 'groupByTestPlan')), guarded withisset(...['qty'])โ 0; - computes
build_qtyvia$tplanMgr->get_builds($tplanSet, null, null, array('getCount' => true)), guarded withisset(...['build_qty'])โ 0; - computes
drawPlatformQtyColumn+ per-planplatform_qtyvia$tplanMgr->platform_mgr->testProjectCount()and$tplanMgr->getPlatforms($idk)(guarded,issetchecks); - computes
rights['testplan_user_role_assignment']via thetplanRoles โ tprojectRoles โ globalRolefallback chain used inplanView.php:106-130.
Rejected alternatives:
- Treating the template: adding
{if isset(...)}guards would hide missing data instead of fixing the data path, and would diverge from the standaloneplanView.phpwhich already provides the keys. - Fixing
planEdit.php'sinitializeGui()ordering: larger blast radius (every testplan mode that uses it) and the enrichment code already exists duplicated inplanView.php; centralising inplanViewGUIInit()fixes the shared template path for both controllers.
Files changed
| File | Change |
|---|---|
lib/plan/planViewUtils.php |
+50: planViewGUIInit() now enriches rows with tcase_qty, build_qty, platform_qty, drawPlatformQtyColumn and per-plan rights |
tmp/TLU_Test_Cases.md |
+Suite 622 (8 test cases, 8/8 PASS) |
Verification
php -l lib/plan/planViewUtils.phpโ "No syntax errors detected".- Cleared
events+gui/templates_c/*.php, then loadedplanEdit.php?tproject_id=1: 0 new level-2 events (pre-fix: 4 per render). Both plans listed with counts 0/0 and per-plan Assign Roles links present (rights populated). - Created 2nd test plan "Second Plan" via UI โ only
audit_testplan_created/audit_users_roles_added_testplan(level-16 INFO) rows; no warnings. - Standalone
planView.phpstill renders clean (no regressions). - Edit form
planEdit.php?do_action=edit&itemID=2clean (planEdit.tpl path). - Inserted
platforms+testplan_platformsโ Platform # column appears,platform_qty=1per plan, events still empty (platform path exercised). - Event Viewer scan across all runs: no new Error/Warning entries.
Regression suite
Suite 622 in tmp/TLU_Test_Cases.md โ 8/8 PASS (pre-fix repro, post-fix clean events,
rights links presence, create flow, standalone planView, edit form, platform column path,
Event Viewer scan).