Skip to content

Commit f9ac941

Browse files
committed
fixed an issue with bad serialization
1 parent 66d83f0 commit f9ac941

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Profiler/ElasticsearchProfiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private function handleRecords($route, $records)
173173
private function addQuery($route, $record, $queryBody)
174174
{
175175
parse_str(parse_url($record['context']['uri'], PHP_URL_QUERY), $httpParameters);
176-
$body = json_decode(trim($queryBody, " '\r\t\n"), true);
176+
$body = json_decode(trim($queryBody, " '\r\t\n"));
177177
$this->queries[$route][] = array_merge(
178178
[
179179
'body' => $body !== null ? json_encode($body, JSON_PRETTY_PRINT) : '',

Tests/Functional/Profiler/ElasticsearchProfilerTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use ONGR\ElasticsearchBundle\Profiler\ElasticsearchProfiler;
1515
use ONGR\ElasticsearchBundle\Tests\app\fixture\Acme\BarBundle\Document\Product;
16+
use ONGR\ElasticsearchDSL\Aggregation\GlobalAggregation;
17+
use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
1618
use ONGR\ElasticsearchDSL\Query\TermQuery;
1719
use ONGR\ElasticsearchBundle\Service\Repository;
1820
use ONGR\ElasticsearchBundle\Test\AbstractElasticsearchTestCase;
@@ -161,4 +163,22 @@ private function getCollector()
161163

162164
return $collector;
163165
}
166+
167+
public function testMatchAllQuery()
168+
{
169+
$manager = $this->getManager();
170+
171+
$repository = $manager->getRepository('AcmeBarBundle:Product');
172+
$search = $repository
173+
->createSearch()
174+
->addAggregation(new GlobalAggregation('g'));
175+
$repository->execute($search);
176+
177+
$queries = $this->getCollector()->getQueries();
178+
$lastQuery = end($queries[ElasticsearchProfiler::UNDEFINED_ROUTE]);
179+
$this->checkQueryParameters($lastQuery);
180+
$lastQuery['body'] = trim(preg_replace('/\s+/', '', $lastQuery['body']));
181+
182+
$this->assertEquals('{"aggregations":{"g":{"global":{}}}}', $lastQuery['body']);
183+
}
164184
}

0 commit comments

Comments
 (0)