Skip to content

Bugfix Issue 977 TcView Warning Key EWarning

opencode edited this page Sep 5, 2026 · 2 revisions

Issue #977 — tcView.tpl E_WARNING Undefined array key "warning" on every Test Case view

Issue: #977 Commit: 6633cb6db (fix) Status: VERIFIED-FIXED (2026-09-05)

Symptom

Rendering the legacy Test Case View (lib/testcases/archiveData.php?edit=testcase&id=N) always logged an E_WARNING into the Event Viewer / events table:

E_WARNING Undefined array key "warning"
  - in gui/templates_c/*_0.file.tcView.tpl.php - Line 69

Cosmetic (the screen renders correctly) but pollutes the Event Viewer on every Test Case view.

Investigation

Reproduced on a fresh DB: created test project Bug977 Project (id=1), suite Bug977 Suite, test case Bug977 TestCase (node id=3). A single GET of archiveData.php?edit=testcase&id=3 grew the events table from 2 → 6 rows (4 events from one render), including event id=3 with the exact reported warning at tcView.tpl.php:69.

Root cause chain

  1. gui/templates/dashio/testcases/tcView.tpl:9-11 builds $labels with {lang_get var='labels' s='no_records_found,...,warning_estimated_execution_duration_format'}.
  2. lang_get_smarty (lib/functions/lang_api.php:194-212) splits the s list on commas and sets one array key per listed string — keys not in the list are never set.
  3. tcView.tpl:39 reads {$labels.warning|escape:'javascript'} (compiled to $labels->value['warning'] at file.tcView.tpl.php:69) → key absent → E_WARNING Undefined array key "warning".

The issue's guess that $TLS_warning is missing from the locale was wrong — the string exists (locale/en_US/strings.txt:217). The sibling screen tcNew.tpl:10 (same label combo) does list warning, confirming tcView.tpl simply omitted it.

Fix (one line)

gui/templates/dashio/testcases/tcView.tpl:9 — prepend warning, to the labels list:

{lang_get var='labels'
          s='warning,no_records_found,other_versions,show_hide_reorder,version,title_test_case,match_count,actions,
             file_upload_ko,warning_estimated_execution_duration_format '}

No PHP or locale changes needed; Smarty recompiles the template automatically.

Why this method (alternatives rejected)

Alternatives like defaulting the Smarty read with |default: or patching lang_get_smarty globally were rejected: the correct, convention-matching fix is declaring the key in the template's own label list (as every other template does). A global patch would mask the same omission elsewhere and would not fix this screen's data contract.

Verification

  • Before: one render wrote event id=3 — Undefined array key "warning".
  • After: same render produces no warning-key event. Compiled template regenerated with s=>'warning,no_records_found,...'; JS alert_box_title is populated ("Warning!!", locale value).
  • Browser console: no new errors on the tcView render.
  • Event Viewer: no new Error/Warning caused by this fix. The three other warnings observed on the same render (inc_relations, value on null, click_to_copy_ghost_to_clipboard) are a separate root cause tracked in issue #978 — untouched here.
  • Regression suite Regression — Issue #977 appended to tmp/TLU_Test_Cases.md (4/4 PASS).

Screenshots

Test Case view after fix

After: docs/screenshots/issue-977-tcview-fixed.png

Files changed

  • gui/templates/dashio/testcases/tcView.tpl (+1/−1) — add warning, to labels s list.
  • docs/Bugfix-Issue-977-TcView-Warning-Key-EWarning.md — bugfix page (docs/ mirror).
  • docs/screenshots/issue-977-tcview-fixed.png — post-fix TC view screenshot.

Clone this wiki locally