Unverified Commit 1b193564 authored by Sergei Morozov's avatar Sergei Morozov Committed by GitHub

Merge pull request #3381 from roger-codina/master

ResultCacheStatement lost its cache capability on fetchAll method
parents f0e93fb8 ecddeb77
...@@ -166,7 +166,10 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement ...@@ -166,7 +166,10 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
*/ */
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{ {
return $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs); $this->data = $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs);
$this->emptied = true;
return $this->data;
} }
/** /**
......
...@@ -166,6 +166,16 @@ class ResultCacheTest extends DbalFunctionalTestCase ...@@ -166,6 +166,16 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertCount(2, $this->sqlLogger->queries); self::assertCount(2, $this->sqlLogger->queries);
} }
public function testFetchAllAndFinishSavesCache()
{
$layerCache = new ArrayCache();
$stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'testcachekey', $layerCache));
$stmt->fetchAll();
$stmt->closeCursor();
self::assertCount(1, $layerCache->fetch('testcachekey'));
}
public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchMode) public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchMode)
{ {
$stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment