From 91808b307a5c59d3f21bdb7eebb0ad2af898ff2a Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Thu, 20 Oct 2016 16:15:41 +0200
Subject: [PATCH] [BUGFIX] Avoid fatal errors in Admin Panel

The functionality to display / explain DB select queries does not
work with DBAL and doctrine anymore.

The leftovers in admin panel caused a fatal PHP error due to a missing
method, which was now removed.

Resolves: #78375
Releases: master
Change-Id: I5cc69508f82855985d3f78449a4672952c633f63
Reviewed-on: https://review.typo3.org/50291
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 typo3/sysext/core/Classes/TimeTracker/TimeTracker.php    | 5 -----
 typo3/sysext/frontend/Classes/View/AdminPanelView.php    | 9 ---------
 typo3/sysext/lang/locallang_tsfe.xlf                     | 3 ---
 .../JavaScript/parse_typoscript/tokenizetyposcript.js    | 1 -
 4 files changed, 18 deletions(-)

diff --git a/typo3/sysext/core/Classes/TimeTracker/TimeTracker.php b/typo3/sysext/core/Classes/TimeTracker/TimeTracker.php
index 6627f237dcc2..67aea8da6da0 100644
--- a/typo3/sysext/core/Classes/TimeTracker/TimeTracker.php
+++ b/typo3/sysext/core/Classes/TimeTracker/TimeTracker.php
@@ -57,7 +57,6 @@ class TimeTracker implements SingletonInterface
         // Determines max length of displayed content FROM FILE cObjects before it gets cropped. Reason is that most FILE cObjects are huge and often used as template-code.
         'flag_tree' => 1,
         'flag_messages' => 1,
-        'flag_queries' => 0,
         'flag_content' => 0,
         'allTime' => 0,
         'keyLgd' => 40
@@ -357,7 +356,6 @@ class TimeTracker implements SingletonInterface
         $flag_tree = $this->printConf['flag_tree'];
         $flag_messages = $this->printConf['flag_messages'];
         $flag_content = $this->printConf['flag_content'];
-        $flag_queries = $this->printConf['flag_queries'];
         $keyLgd = $this->printConf['keyLgd'];
         $c = 0;
         foreach ($this->tsStackLog as $uniqueId => $data) {
@@ -417,9 +415,6 @@ class TimeTracker implements SingletonInterface
                     $msgArr[] = nl2br($v);
                 }
             }
-            if ($flag_queries && is_array($data['selectQuery'])) {
-                $msgArr[] = \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($data['selectQuery']);
-            }
             if ($flag_content && (string)$data['content'] !== '') {
                 $maxlen = 120;
                 // Break lines which are too longer than $maxlen chars (can happen if content contains long paths...)
diff --git a/typo3/sysext/frontend/Classes/View/AdminPanelView.php b/typo3/sysext/frontend/Classes/View/AdminPanelView.php
index e4812a33c648..d1cdf9c2ec68 100644
--- a/typo3/sysext/frontend/Classes/View/AdminPanelView.php
+++ b/typo3/sysext/frontend/Classes/View/AdminPanelView.php
@@ -84,13 +84,6 @@ class AdminPanelView
         $typoScriptFrontend->forceTemplateParsing = $this->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
         $typoScriptFrontend->displayEditIcons = $this->extGetFeAdminValue('edit', 'displayIcons');
         $typoScriptFrontend->displayFieldEditIcons = $this->extGetFeAdminValue('edit', 'displayFieldIcons');
-        if ($this->extGetFeAdminValue('tsdebug', 'displayQueries')) {
-            // Do not override if the value is already set in \TYPO3\CMS\Core\Database\DatabaseConnection
-            if ($this->getDatabaseConnection()->explainOutput == 0) {
-                // Enable execution of EXPLAIN SELECT queries
-                $this->getDatabaseConnection()->explainOutput = 3;
-            }
-        }
         if (GeneralUtility::_GP('ADMCMD_editIcons')) {
             $typoScriptFrontend->displayFieldEditIcons = 1;
         }
@@ -525,14 +518,12 @@ class AdminPanelView
             $out .= $this->extGetItem('tsdebug_displayMessages', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0" /><input type="checkbox" id="tsdebug_displayMessages" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_displayMessages'] ? ' checked="checked"' : '') . ' />');
             $out .= $this->extGetItem('tsdebug_LR', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0" /><input type="checkbox" id="tsdebug_LR" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_LR'] ? ' checked="checked"' : '') . ' />');
             $out .= $this->extGetItem('tsdebug_displayContent', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0" /><input type="checkbox" id="tsdebug_displayContent" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_displayContent'] ? ' checked="checked"' : '') . ' />');
-            $out .= $this->extGetItem('tsdebug_displayQueries', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="0" /><input type="checkbox" id="tsdebug_displayQueries" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_displayQueries'] ? ' checked="checked"' : '') . ' />');
             $out .= $this->extGetItem('tsdebug_forceTemplateParsing', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0" /><input type="checkbox" id="tsdebug_forceTemplateParsing" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing'] ? ' checked="checked"' : '') . ' />');
             $timeTracker = $this->getTimeTracker();
             $timeTracker->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug', 'tree');
             $timeTracker->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug', 'displayTimes');
             $timeTracker->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug', 'displayMessages');
             $timeTracker->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug', 'displayContent');
-            $timeTracker->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug', 'displayQueries');
             $out .= $this->extGetItem('', $timeTracker->printTSlog(), '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper scroll-table');
         }
         return $out;
diff --git a/typo3/sysext/lang/locallang_tsfe.xlf b/typo3/sysext/lang/locallang_tsfe.xlf
index bcd8d5c2f20c..498ba9051b33 100644
--- a/typo3/sysext/lang/locallang_tsfe.xlf
+++ b/typo3/sysext/lang/locallang_tsfe.xlf
@@ -111,9 +111,6 @@
 			<trans-unit id="tsdebug_displayContent">
 				<source>Display content</source>
 			</trans-unit>
-			<trans-unit id="tsdebug_displayQueries">
-				<source>Explain SELECT queries</source>
-			</trans-unit>
 			<trans-unit id="info">
 				<source>Info</source>
 			</trans-unit>
diff --git a/typo3/sysext/t3editor/Resources/Public/JavaScript/parse_typoscript/tokenizetyposcript.js b/typo3/sysext/t3editor/Resources/Public/JavaScript/parse_typoscript/tokenizetyposcript.js
index 3c69e6aeae98..fda2d13c43d9 100644
--- a/typo3/sysext/t3editor/Resources/Public/JavaScript/parse_typoscript/tokenizetyposcript.js
+++ b/typo3/sysext/t3editor/Resources/Public/JavaScript/parse_typoscript/tokenizetyposcript.js
@@ -278,7 +278,6 @@ var typoscriptWords = {
 	'displayFieldIcons': 'reserved',
 	'displayIcons': 'reserved',
 	'displayMessages': 'reserved',
-	'displayQueries': 'reserved',
 	'displayRecord': 'reserved',
 	'displayTimes': 'reserved',
 	'distributeX': 'reserved',
-- 
GitLab