[BUGFIX] Possible failure in dependency injection
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 17 Aug 2012 13:36:56 +0000 (15:36 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 17 Aug 2012 13:48:01 +0000 (15:48 +0200)
Extbase reflection cache calls not existing methods. This can
happen for example if a class is refactored and an injectMethod
has been dropped.

Change-Id: I30071b53f300ef340d6c882ed40f0f67fb86c440
Fixes: #39892
Related: #39174
Releases: 6.0, 4.7
Reviewed-on: http://review.typo3.org/13864
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extbase/Classes/Object/Container/Container.php

index b404621..440547e 100644 (file)
@@ -226,7 +226,9 @@ class Tx_Extbase_Object_Container_Container implements t3lib_Singleton {
                                $this->log('The singleton "' . $classInfo->getClassName() . '" needs a prototype in "' . $injectMethodName . '". This is often a bad code smell; often you rather want to inject a singleton.', 1);
                        }
 
-                       $instance->$injectMethodName($instanceToInject);
+                       if (is_callable(array($instance, $injectMethodName))) {
+                               $instance->$injectMethodName($instanceToInject);
+                       }
                }
 
                foreach ($classInfo->getInjectProperties() as $injectPropertyName => $classNameToInject) {