Bugfix Issue 613 FrmInner Chosen Before JQuery - sebiboga/testlink-upgraded GitHub Wiki
Date: 2026-08-28 ยท Branch: fix/issue-613 ยท Commits: dbd80bdde (fix), 4775da557 (test)
Every load of lib/general/frmWorkArea.php (the workarea inner frame that hosts the
tree + work frame iframes) fired two uncaught JavaScript errors in the frame document:
Uncaught ReferenceError: jQuery is not defined (chosen.jquery.js:622:3)
Uncaught Error: Bootstrap's JavaScript requires jQuery (bootstrap.min.js:6:37)
The template gui/templates/dashio/frmInner.tpl loaded the chosen jQuery plugin โ and
bootstrap.min.js โ in a document that never loaded jQuery at all. The child iframes
worked because they load their own jQuery, so the bug was purely cosmetic/robustness:
console noise on every workarea load plus a guaranteed failure for any future inline
jQuery use on that page. Below, the workarea after the fix renders normally (treeframe +
workframe), with a console free of the two uncaught errors.

- Open any legacy workarea feature (
frmWorkArea.php?feature=searchTc,feature=printTestSpec,executeTest,planAddTC,showMetrics,reqSpecMgmt, โฆ). - DevTools console of the
frmWorkArea.phpdocument shows exactly the two errors above. - Network panel:
chosen.jquery.jsandbootstrap.min.jsload with no jQuery script tag present in that document (jQuery is only fetched by the child iframes).
Chain:
-
lib/general/frmWorkArea.php:171renders the frame page with$smarty->display('frmInner.tpl')(dashio template dir,tlsmarty.inc.php:101). -
gui/templates/dashio/frmInner.tpl:20emitted thechosen.jquery.jsscript tag โ a jQuery plugin whose IIFE dereferencesjQueryimmediately (chosen.jquery.js:622), throwingReferenceError: jQuery is not defined. -
gui/templates/dashio/frmInner.tpl:22{include file="bootstrap.inc.tpl"}emitsbootstrap.min.js, whose loader throwsBootstrap's JavaScript requires jQueryat runtime (bootstrap.min.js:6). - The frmInner document never loads jQuery itself: the only jQuery script
(
TL_JQUERY=third_party/jquery/jquery-2.2.4.min.js, defined inconfig.inc.php:2161) was loaded by the child tree/work frames, not by the parent.
Correction to the issue body's premise: the report assumed bootstrap.inc.tpl is
"the include that loads jQuery". That is not the case in either
gui/templates/dashio/include/bootstrap.inc.tpl or the tl-classic variant โ it only
loads bootstrap CSS + bootstrap.min.js. Consequently:
-
frmInner.tplwas the only genuinely broken site (chosen and bootstrap both ran with jQuery undefined). -
workbench.tplalready loadedTL_JQUERYbeforechosen.jquery.js, so its order was already correct; it is also orphaned (no PHP references). No change was needed there.
Blast radius: every legacy feature opened through frmWorkArea.php?feature=โฆ.
Grep of chosen in dashio .tpl: only frmInner.tpl:20 and workbench.tpl:24; only
frmWorkArea.php:171 renders frmInner.tpl.
gui/templates/dashio/frmInner.tpl โ inserted the standard TL_JQUERY script tag
before the chosen.jquery.js include, so the head order becomes
jQuery โ chosen โ bootstrap (the same order the legacy tl-classic head uses):
+<script type="text/javascript" src="{$basehref}{$smarty.const.TL_JQUERY}"></script>
<script type="text/javascript" src="{$basehref}third_party/chosen/chosen.jquery.js"></script>
{include file="bootstrap.inc.tpl"}
Approach: minimal +1 line. Reuses the already-defined TL_JQUERY constant, keeps the
exact template structure, and satisfies both plugins' jQuery requirement. The stale
compiled template gui/templates_c/*frmInner*.php was deleted so Smarty regenerates it.
-
gui/templates/dashio/frmInner.tplโ +1 (jQuery tag before chosen/bootstrap). -
tmp/TLU_Test_Cases.mdโ regression suite 613 (613.1โ613.5, all PASS).
-
frmWorkArea.php?feature=searchTc: console 0 uncaught errors (was 2); parent frame fetchesjquery-2.2.4.min.js[200] โchosen.jquery.js[200] โbootstrap.min.js[200]. - Frame probe:
jQuery.fn.jquery === '2.2.4',typeof jQuery.fn.chosen === 'function'(plugin registered in the parent frame). -
frmWorkArea.php?feature=printTestSpec: 0 uncaught errors. - Main dashboard reload: no new errors.
-
eventstable: no new ERROR/WARNING rows (onlyaudit_login_succeeded, log_level=16). - Note:
tcSearchForm.php[500] seen during repro is pre-existing and unrelated (Error Processing Request - Invalid Test project id,tcSearchForm.php:45, fires withtproject_id=0).
| Case | Result |
|---|---|
frmWorkArea.php?feature=searchTc โ 0 uncaught JS errors; correct script order |
โ |
frmWorkArea.php?feature=printTestSpec โ 0 uncaught JS errors |
โ |
| Main dashboard reload โ no new errors | โ |
Chosen plugin registered in frame (jQuery.fn.chosen) |
โ |
Event Viewer / events โ no new Error/Warning entries |
โ |