Clean filtered objects if the entire batch was filtered away, to prevent memory allocation issue.

This commit is contained in:
Nikolai Zujev 2014-11-13 17:14:36 +02:00 committed by Tim Nagel
parent 67ae044309
commit c45dcd955d
2 changed files with 30 additions and 0 deletions

View file

@ -69,6 +69,10 @@ abstract class AbstractProvider extends BaseAbstractProvider
$loggerClosure('<info>Entire batch was filtered away, skipping...</info>'); $loggerClosure('<info>Entire batch was filtered away, skipping...</info>');
} }
if ($this->options['clear_object_manager']) {
$manager->clear();
}
continue; continue;
} }

View file

@ -122,6 +122,32 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
$provider->populate(); $provider->populate();
} }
public function testPopulateShouldClearObjectManagerForFilteredBatch()
{
$nbObjects = 1;
$objects = array(1);
$provider = $this->getMockAbstractProvider();
$provider->expects($this->any())
->method('countObjects')
->will($this->returnValue($nbObjects));
$provider->expects($this->any())
->method('fetchSlice')
->will($this->returnValue($objects));
$this->indexable->expects($this->any())
->method('isObjectIndexable')
->with('index', 'type', $this->anything())
->will($this->returnValue(false));
$this->objectManager->expects($this->once())
->method('clear');
$provider->populate();
}
public function testPopulateInvokesLoggerClosure() public function testPopulateInvokesLoggerClosure()
{ {
$nbObjects = 1; $nbObjects = 1;