From 6de4d039d1601cfdd1cc9350cff7956a4704fde8 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 19 Apr 2018 10:55:34 +0200 Subject: [PATCH] Fix explaining queries Recent Symfony versions are wrapping the params in a VarDumper Data when collecting the profiler info. This ensures that they get unwrapped properly when trying to explain the query. --- Controller/ProfilerController.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Controller/ProfilerController.php b/Controller/ProfilerController.php index 9d1e76924..5f7c89dd0 100644 --- a/Controller/ProfilerController.php +++ b/Controller/ProfilerController.php @@ -8,6 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Profiler\Profiler; +use Symfony\Component\VarDumper\Cloner\Data; /** * ProfilerController. @@ -77,14 +78,27 @@ private function explainSQLServerPlatform(Connection $connection, $query) } else { $sql = 'SET SHOWPLAN_TEXT ON; GO; SET NOEXEC ON; ' . $query['sql'] . '; SET NOEXEC OFF; GO; SET SHOWPLAN_TEXT OFF;'; } - $stmt = $connection->executeQuery($sql, $query['params'], $query['types']); + + $params = $query['params']; + + if ($params instanceof Data) { + $params = $params->getValue(true); + } + + $stmt = $connection->executeQuery($sql, $params, $query['types']); $stmt->nextRowset(); return $stmt->fetchAll(\PDO::FETCH_ASSOC); } private function explainOtherPlatform(Connection $connection, $query) { - return $connection->executeQuery('EXPLAIN ' . $query['sql'], $query['params'], $query['types']) + $params = $query['params']; + + if ($params instanceof Data) { + $params = $params->getValue(true); + } + + return $connection->executeQuery('EXPLAIN ' . $query['sql'], $params, $query['types']) ->fetchAll(\PDO::FETCH_ASSOC); } }