Clean filtered objects if the entire batch was filtered away, to prevent memory allocation issue.
This commit is contained in:
parent
67ae044309
commit
c45dcd955d
|
@ -69,6 +69,10 @@ abstract class AbstractProvider extends BaseAbstractProvider
|
|||
$loggerClosure('<info>Entire batch was filtered away, skipping...</info>');
|
||||
}
|
||||
|
||||
if ($this->options['clear_object_manager']) {
|
||||
$manager->clear();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,32 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
|||
$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()
|
||||
{
|
||||
$nbObjects = 1;
|
||||
|
|
Loading…
Reference in a new issue