[BUGFIX] Prevent javascript error in backend 14/54714/5
authorMarkus Günther <mail@markus-guenther.de>
Mon, 20 Nov 2017 08:18:27 +0000 (09:18 +0100)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Mon, 8 Jan 2018 09:46:53 +0000 (10:46 +0100)
Adding a condition to check if a backend user has permissions on the
search to prevent a JS error while initializing the autocomplete module.
Also check if a module is available to start with.

Fixes: #82969
Releases: master, 8.7, 7.6
Change-Id: If2827902443ff7411d9b2c1050213be3e0d78fb6
Reviewed-on: https://review.typo3.org/54714
Reviewed-by: Markus Günther <mail@markus-guenther.de>
Tested-by: Markus Günther <mail@markus-guenther.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Henning Liebe <h.liebe@neusta.de>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js
typo3/sysext/backend/Resources/Public/JavaScript/modulemenu.js

index c6d9dfa..4bea1e5 100644 (file)
@@ -87,10 +87,12 @@ define(['jquery', 'jquery/autocomplete', 'TYPO3/CMS/Backend/jquery.clearable'],
                        evt.preventDefault();
                        TYPO3.ModuleMenu.App.showModule('web_list', 'id=0&search_levels=4&search_field=' + encodeURIComponent($(searchFieldSelector).val()));
                });
-               $(containerSelector + ' .' + $(searchFieldSelector).autocomplete().options.containerClass).on('click.autocomplete', '.dropdown-list-link', function(evt) {
-                       evt.preventDefault();
-                       jump($(this).data('target'), 'web_list', 'web', $(this).data('pageid'));
-               });
+               if ($(searchFieldSelector).length) {
+                       $(containerSelector + ' .' + $(searchFieldSelector).autocomplete().options.containerClass).on('click.autocomplete', '.dropdown-list-link', function(evt) {
+                               evt.preventDefault();
+                               jump($(this).data('target'), 'web_list', 'web', $(this).data('pageid'));
+                       });
+               }
 
                $(searchFieldSelector).clearable({
                        onClear: function() {
index c01a76c..b167087 100644 (file)
@@ -34,7 +34,9 @@ TYPO3.ModuleMenu.App = {
                        me.showModule(top.startInModule[0], top.startInModule[1]);
                } else {
                        // fetch first module
-                       me.showModule(TYPO3.jQuery('.t3js-mainmodule:first').attr('id'));
+                       if (TYPO3.jQuery('.t3js-mainmodule:first').length) {
+                               me.showModule(TYPO3.jQuery('.t3js-mainmodule:first').attr('id'));
+                       }
                }
 
                // check if there are collapsed items in the users' configuration