From 6b6edb6ea7b8194036d2d0b343ef7a9ddcc649e3 Mon Sep 17 00:00:00 2001
From: Georg Ringer <georg.ringer@gmail.com>
Date: Wed, 11 Jan 2023 08:22:39 +0100
Subject: [PATCH] [TASK] Show explain selection in DB check only for Mysql

As the selection "explain" only works for Mysql, it should also only be
displayed then.

Resolves: #99512
Releases: main, 11.5
Change-Id: I93ddf86d1f63ef124feb2b72e86f32d8260ad99f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77395
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Classes/Controller/DatabaseIntegrityController.php   | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php b/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
index f015579be8e0..294cdfdecd98 100644
--- a/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
+++ b/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
@@ -15,6 +15,7 @@
 
 namespace TYPO3\CMS\Lowlevel\Controller;
 
+use Doctrine\DBAL\Platforms\MySqlPlatform;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Routing\UriBuilder;
@@ -22,6 +23,7 @@ use TYPO3\CMS\Backend\Template\Components\ButtonBar;
 use TYPO3\CMS\Backend\Template\ModuleTemplate;
 use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Imaging\Icon;
@@ -235,6 +237,13 @@ class DatabaseIntegrityController
             ],
             'sword' => '',
         ];
+
+        // EXPLAIN is no ANSI SQL, for now this is only executed on mysql
+        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
+        if (!$connection->getDatabasePlatform() instanceof MySQLPlatform) {
+            unset($this->MOD_MENU['search_query_makeQuery']['explain']);
+        }
+
         // CLEAN SETTINGS
         $OLD_MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, [], $this->moduleName, 'ses');
         $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName, 'ses');
-- 
GitLab