From 56822a6b58646495a4a382f2ac533ccdfc8a5ad8 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Sun, 22 Feb 2026 20:10:47 +0100 Subject: [PATCH 1/5] Fix Uncaught ReferenceError: CodeMirror is not defined Signed-off-by: Liviu-Mihail Concioiu --- libraries/classes/Header.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/classes/Header.php b/libraries/classes/Header.php index 7916094469..558ad289c1 100644 --- a/libraries/classes/Header.php +++ b/libraries/classes/Header.php @@ -334,7 +334,8 @@ class Header // The user preferences have been merged at this point // so we can conditionally add CodeMirror, other scripts and settings - if ($GLOBALS['cfg']['CodemirrorEnable']) { + // See #20159, why we need to check for HTTP_USER_AGENT here + if ($GLOBALS['cfg']['CodemirrorEnable'] && isset($_SERVER['HTTP_USER_AGENT'])) { $this->scripts->addFile('vendor/codemirror/lib/codemirror.js'); $this->scripts->addFile('vendor/codemirror/mode/sql/sql.js'); $this->scripts->addFile('vendor/codemirror/addon/runmode/runmode.js'); From 9ce6792f2b36e0b320e64ce214d76e07d35f687b Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Sun, 22 Feb 2026 21:11:13 +0100 Subject: [PATCH 2/5] Implement userAgent function Signed-off-by: Liviu-Mihail Concioiu --- js/src/functions.js | 13 ++++++++++++- js/src/makegrid.js | 10 +++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/js/src/functions.js b/js/src/functions.js index ce9532f20c..3f308169a3 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -103,6 +103,17 @@ $.ajaxPrefilter(function (options, originalOptions) { } }); +/** + * Get an empty string for user-agent, if undefined + */ +Functions.userAgent = function () { + try { + return navigator.userAgent; + } catch { + return ''; + } +}; + /** * Adds a date/time picker to an element * @@ -1095,7 +1106,7 @@ AJAX.registerOnload('functions.js', function () { /** * Add attribute to text boxes for iOS devices (based on bugID: 3508912) */ - if (navigator.userAgent.match(/(iphone|ipod|ipad)/i)) { + if (Functions.userAgent().match(/(iphone|ipod|ipad)/i)) { $('input[type=text]').attr('autocapitalize', 'off').attr('autocorrect', 'off'); } }); diff --git a/js/src/makegrid.js b/js/src/makegrid.js index 54bef74551..74dd32680a 100644 --- a/js/src/makegrid.js +++ b/js/src/makegrid.js @@ -260,7 +260,7 @@ var makeGrid = function (t, enableResize, enableReorder, enableVisib, enableGrid for (var n = 0, l = $firstRowCols.length; n < l; n++) { var $col = $($firstRowCols[n]); var colWidth; - if (navigator.userAgent.toLowerCase().indexOf('safari') !== -1) { + if (Functions.userAgent().toLowerCase().indexOf('safari') !== -1) { colWidth = $col.outerWidth(); } else { colWidth = $col.outerWidth(true); @@ -2317,10 +2317,10 @@ var makeGrid = function (t, enableResize, enableReorder, enableVisib, enableGrid $.fn.noSelect = function (p) { // no select plugin by Paulo P.Marinas var prevent = (p === null) ? true : p; /* eslint-disable compat/compat */ - var isMsie = navigator.userAgent.indexOf('MSIE') > -1 || !!window.navigator.userAgent.match(/Trident.*rv:11\./); - var isFirefox = navigator.userAgent.indexOf('Firefox') > -1; - var isSafari = navigator.userAgent.indexOf('Safari') > -1; - var isOpera = navigator.userAgent.indexOf('Presto') > -1; + var isMsie = Functions.userAgent().indexOf('MSIE') > -1 || !!Functions.userAgent().match(/Trident.*rv:11\./); + var isFirefox = Functions.userAgent().indexOf('Firefox') > -1; + var isSafari = Functions.userAgent().indexOf('Safari') > -1; + var isOpera = Functions.userAgent().indexOf('Presto') > -1; /* eslint-enable compat/compat */ if (prevent) { return this.each(function () { From 1dc05380989cdd1b0cc9c1b51da0f097697f48e6 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Sun, 22 Feb 2026 21:40:54 +0100 Subject: [PATCH 3/5] Fix js-lint Signed-off-by: Liviu-Mihail Concioiu --- js/src/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/functions.js b/js/src/functions.js index 3f308169a3..ecc1a5bdd4 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -109,7 +109,7 @@ $.ajaxPrefilter(function (options, originalOptions) { Functions.userAgent = function () { try { return navigator.userAgent; - } catch { + } catch (e) { return ''; } }; From 0a2af932bbe8048293f6d785463031c780a1fb61 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Sun, 22 Feb 2026 21:44:09 +0100 Subject: [PATCH 4/5] Fix js-lint Signed-off-by: Liviu-Mihail Concioiu --- js/src/functions.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/src/functions.js b/js/src/functions.js index ecc1a5bdd4..66bde267ea 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -105,6 +105,8 @@ $.ajaxPrefilter(function (options, originalOptions) { /** * Get an empty string for user-agent, if undefined + * + * @return {string} */ Functions.userAgent = function () { try { From aa812dba65970d0ca590251258712600b0a96a64 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Mon, 23 Feb 2026 13:09:08 +0100 Subject: [PATCH 5/5] Show error in console Signed-off-by: Liviu-Mihail Concioiu --- js/src/functions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/src/functions.js b/js/src/functions.js index 66bde267ea..e42f853d03 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -112,6 +112,7 @@ Functions.userAgent = function () { try { return navigator.userAgent; } catch (e) { + console.error(e); return ''; } };