Skip to content

Commit

Permalink
Fix crash when no post processor is defined
Browse files Browse the repository at this point in the history
Exception:

> ContextErrorException: Notice: Undefined index: post_processors in /var/www/foo/vendor/liip/imagine-bundle/Liip/ImagineBundle/Imagine/Filter/FilterManager.php line 144

This happens in eZ Publish, where post processors are not (yet) supported.

Ping @crevillo
  • Loading branch information
lolautruche committed Nov 12, 2014
1 parent c8b6eca commit f0b5d9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions Imagine/Filter/FilterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function apply(BinaryInterface $binary, array $config)
*/
public function applyPostProcessors(BinaryInterface $binary, $config)
{
$config += array('post_processors' => array());
foreach ($config['post_processors'] as $postProcessorName => $postProcessorOptions) {
if (!isset($this->postProcessors[$postProcessorName])) {
throw new \InvalidArgumentException(sprintf(
Expand Down
12 changes: 12 additions & 0 deletions Tests/Imagine/Filter/FilterManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,18 @@ public function testThrowsIfNoPostProcessorAddedForFilterOnApplyFilter()
$filterManager->applyFilter($binary, 'thumbnail');
}

public function testApplyPostProcessorsWhenNotDefined()
{
$binary = $this->getMock('Liip\ImagineBundle\Binary\BinaryInterface');
$filterManager = new FilterManager(
$this->createFilterConfigurationMock(),
$this->createImagineMock(),
$this->getMockMimeTypeGuesser()
);

$this->assertSame($binary, $filterManager->applyPostProcessors($binary, array()));
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|LoaderInterface
*/
Expand Down

0 comments on commit f0b5d9b

Please sign in to comment.