Skip to content

Commit 3b7bb6b

Browse files
committed
Fix issue which prevent the profiler to explain a query
1 parent 87f83f7 commit 3b7bb6b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ private function sanitizeQueries($connectionName, $queries)
117117
private function sanitizeQuery($connectionName, $query)
118118
{
119119
$query['explainable'] = true;
120+
if (null === $query['params']) {
121+
$query['params'] = array();
122+
}
120123
if (!is_array($query['params'])) {
121124
$query['params'] = array($query['params']);
122125
}

src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,22 @@ public function testCollectQueries($param, $types, $expected, $explainable)
8484
$this->assertEquals($explainable, $collected_queries['default'][0]['explainable']);
8585
}
8686

87+
public function testCollectQueryWithNoParams()
88+
{
89+
$queries = array(
90+
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1),
91+
array('sql' => 'SELECT * FROM table1', 'params' => null, 'types' => null, 'executionMS' => 1),
92+
);
93+
$c = $this->createCollector($queries);
94+
$c->collect(new Request(), new Response());
95+
96+
$collected_queries = $c->getQueries();
97+
$this->assertEquals(array(), $collected_queries['default'][0]['params']);
98+
$this->assertTrue($collected_queries['default'][0]['explainable']);
99+
$this->assertEquals(array(), $collected_queries['default'][1]['params']);
100+
$this->assertTrue($collected_queries['default'][1]['explainable']);
101+
}
102+
87103
/**
88104
* @dataProvider paramProvider
89105
*/

0 commit comments

Comments
 (0)