Bugfix Issue 520 Missing GuiProperties Dashio Templates - sebiboga/testlink-upgraded GitHub Wiki
Bugfix — Issue #520: E_WARNING Multiple Missing $gui Properties in Dashio Templates
Problem
PHP 8.x emits E_WARNING: Undefined property on every page load for several
dashio templates that reference $gui or $tlCfg properties that were never
initialized by their PHP controllers.
Root Cause
When dashio templates were ported from the classic theme, some property references were carried over but the corresponding PHP initializations were missed:
| Property | Template | PHP Controller | Cause |
|---|---|---|---|
$gui->doViewReload |
plan/planView.tpl:204 |
lib/plan/planView.php::initializeGui() |
Never set (set in planEdit.php and projectView.php but not planView.php) |
$tlCfg->layout->cellContent |
plan/planEdit.tpl:31 |
Entire codebase | $tlCfg->layout was never defined; phantom config reference |
$tlCfg->layout->cellLabel |
plan/planEdit.tpl:32 |
Entire codebase | Same |
$gui->tprojOpt |
plan/tc_exec_assignment_flat.tpl:236,288,296 |
lib/plan/tc_exec_assignment.php:222-224 |
PHP computed $tprojOpt locally but assigned $gui->testPriorityEnabled (scalar) instead of $gui->tprojOpt (object) |
$gui->tplan_id |
testcases/containerNew.tpl:44 |
lib/functions/testsuite.class.php::viewer_edit_new() |
No safety guard; callers set it but function itself doesn't ensure it exists |
Fix
Four minimal changes:
-
lib/plan/planView.php:187— Added$gui->doViewReload = false;ininitializeGui(), matching the pattern fromplanEdit.php:460andprojectView.php:127. -
gui/templates/dashio/plan/planEdit.tpl:31-32— Replaced$tlCfg->layout->cellContentand$tlCfg->layout->cellLabelwith hardcoded Bootstrap grid defaults (col-sm-9andcol-sm-3), matching theform-horizontalpattern used throughout dashio. -
lib/plan/tc_exec_assignment.php:224— Added$gui->tprojOpt = is_object($tprojOpt) ? $tprojOpt : new stdClass();to properly assign the already-computed$tprojOptobject to the gui variable that the template expects. -
gui/templates/dashio/testcases/containerNew.tpl:44— Addedisset()guard:{if isset($gui->tplan_id)}{$gui->tplan_id}{else}0{/if}, consistent with the existingproperty_existsguard pattern used elsewhere (e.g.,keywords.inc.tpl).
Verification
- All 3 modified PHP files pass
php -lsyntax check. - planView page renders correctly, no console errors.
- planEdit form renders correctly with Bootstrap grid layout, no console errors.
- containerNew form renders correctly, no errors.
- Screenshot:
docs/screenshots/issue-520-planEdit-no-warnings.png