Index: tests/suite.php
===================================================================
--- tests/suite.php	(revision 24327)
+++ tests/suite.php	(working copy)
@@ -20,6 +20,7 @@
         $this->addTestSuite( 'eZSOAPTestSuite' );
         $this->addTestSuite( 'eZLocaleTestSuite' );
         $this->addTestSuite( 'eZTemplateTestSuite' );
+        $this->addTestSuite( 'eZImageTestSuite' );
     }
 
     public static function suite()
Index: tests/tests/lib/ezimage/suite.php
===================================================================
--- tests/tests/lib/ezimage/suite.php	(revision 0)
+++ tests/tests/lib/ezimage/suite.php	(revision 0)
@@ -0,0 +1,26 @@
+<?php
+/**
+ * File containing the eZImageTestSuite class
+ *
+ * @copyright Copyright (C) 1999-2009 eZ Systems AS. All rights reserved.
+ * @license http://ez.no/licenses/gnu_gpl GNU GPLv2
+ * @package tests
+ */
+
+class eZImageTestSuite extends ezpDatabaseTestSuite
+{
+    public function __construct()
+    {
+        parent::__construct();
+        $this->setName( "eZImage Test Suite" );
+
+        $this->addTestSuite( 'eZImageManagerTest' );
+    }
+
+    public static function suite()
+    {
+        return new self();
+    }
+}
+
+?>
Index: tests/tests/lib/ezimage/ezimagemanager_test.php
===================================================================
--- tests/tests/lib/ezimage/ezimagemanager_test.php	(revision 0)
+++ tests/tests/lib/ezimage/ezimagemanager_test.php	(revision 0)
@@ -0,0 +1,67 @@
+<?php
+
+class eZImageManagerTest extends ezpTestCase
+{
+    public static function gdIsEnabled()
+    {
+        return function_exists( 'gd_info' );
+    }
+
+    public static function imageMagickIsEnabled()
+    {
+        $imageIni = eZINI::instance( 'image.ini' );
+        return ( in_array( 'ImageMagick', $imageIni->variable( 'ImageConverterSettings', 'ImageConverters' ) ) and
+                 $imageIni->variable( 'ImageMagick', 'IsEnabled' ) == 'true' );
+    }
+
+    public function setUp()
+    {
+        parent::setUp();
+
+        $this->imageIni = eZINI::instance( 'image.ini' );
+    }
+
+    /**
+     * Test scenario for image alias using filters from multiple image handlers
+     * for issue #15773: Infinite loop in ImageManager when using filters from multiple image handlers
+     *
+     * Test Outline
+     * ------------
+     * 1. Setup alias with filters from multiple image handlers
+     * 2. Load image manager
+     * 3. Backup max_execution_time, set it to 60 seconds
+     * 4. Convert image
+     * 5. Restore max_execution_time
+     *
+     * @result:
+     *   The operation times out after 60 seconds
+     * @expected:
+     *   The conversion call returns true
+     * @link http://issues.ez.no/15773
+     */
+    public function testMultiHandlerAlias()
+    {
+        if ( !self::gdIsEnabled() or !self::imageMagickIsEnabled() )
+            $this->markTestSkipped( 'GD and/or ImageMagick are not enabled' );
+
+        $aliasList = $this->imageIni->variable( 'AliasSettings', 'AliasList' );
+        array_push( $aliasList, 'multihandler' );
+        $this->imageIni->setVariable( 'AliasSettings', 'AliasList', $aliasList );
+        $this->imageIni->setVariable( 'multihandler', 'Reference', '' );
+        $this->imageIni->setVariable( 'multihandler', 'Filters', array( 'luminance/gray', 'filter/swirl=210' ) );
+
+        $sourcePath = 'tests/tests/lib/ezimage/data/andernach.jpg';
+        $targetPath = 'tests/tests/lib/ezimage/data/andernach_result.jpg';
+        $img = eZImageManager::instance();
+        $img->readINISettings();
+
+        $timeLimit = ini_get( 'max_execution_time' );
+        set_time_limit( 60 );
+        $result = $img->convert( $sourcePath, $targetPath, 'multihandler' );
+        set_time_limit( $timeLimit );
+
+        $this->assertEquals( true, $result );
+    }
+}
+
+?>
Index: tests/tests/lib/ezimage/data/andernach.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tests/tests/lib/ezimage/data/andernach.jpg
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + application/octet-stream

Index: lib/ezimage/classes/ezimagemanager.php
===================================================================
--- lib/ezimage/classes/ezimagemanager.php	(revision 24327)
+++ lib/ezimage/classes/ezimagemanager.php	(working copy)
@@ -1177,8 +1177,19 @@
                 {
                     if ( !$handler )
                         continue;
+
+                    $handlerFilters = array();
+                    $leftoverFilters = array();
+                    foreach ( $filters as $filter )
+                    {
+                        if ( $handler->isFilterSupported( $filter ) )
+                            $handlerFilters[] = $filter;
+                        else
+                            $leftoverFilters[] = $filter;
+                    }
+
                     $outputMimeData = $handler->outputMIMEType( $this, $currentMimeData, $destinationMimeData, $this->SupportedFormats, $aliasName );
-                    if ( $outputMimeData['name'] == $destinationMimeData['name'] )
+                    if ( $outputMimeData['name'] == $destinationMimeData['name'] and count( $handlerFilters ) > 0 )
                     {
                         $nextMimeData = $outputMimeData;
                         $nextHandler = $handler;
@@ -1199,15 +1210,7 @@
                         $sourceFile->deleteLocal();
                     return false;
                 }
-                $handlerFilters = array();
-                $leftoverFilters = array();
-                foreach ( $filters as $filter )
-                {
-                    if ( $nextHandler->isFilterSupported( $filter ) )
-                        $handlerFilters[] = $filter;
-                    else
-                        $leftoverFilters[] = $filter;
-                }
+
                 $useTempImage = false;
                 if ( $nextMimeData['name'] == $destinationMimeData['name'] and
                      count( $leftoverFilters ) == 0 )
