Bug #46716
Empty class names in DependencyInjection proxy code when using Caches / Factory-created dependencies
Status: | New | Start date: | 2013-03-19 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | Object | |||
Target version: | TYPO3 Flow Base Distribution - 2.0.1 | |||
PHP Version: | Complexity: | |||
Has patch: | No | Affected Flow version: | Git master |
Description
I noticed a few cases where the $className argument of \TYPO3\Flow\Object\ObjectManager::createLazyDependency
was an empty string; that is the case, for example, in
\TYPO3\Flow\Resource\ResourceManager::Flow_Proxy_injectProperties
:
1 /**
2 * Autogenerated Proxy Method
3 */
4 private function Flow_Proxy_injectProperties() {
5 $statusCache_reference = &$this->statusCache;
6 $this->statusCache = \TYPO3\Flow\Core\Bootstrap::$staticObjectManager->getLazyDependencyByHash('b3ca84fd627a5045e163e999a38877bf', $statusCache_reference);
7 if ($this->statusCache === NULL) {
8 $this->statusCache = \TYPO3\Flow\Core\Bootstrap::$staticObjectManager->createLazyDependency('b3ca84fd627a5045e163e999a38877bf', $statusCache_reference, '', function() { return \TYPO3\Flow\Core\Bootstrap::$staticObjectManager->get('TYPO3\Flow\Cache\CacheManager')->getCache('Flow_Resource_Status'); });
9 }
10 // etc...
The complete generated class file can be seen here: https://gist.github.com/afoeder/18b878d29c418b313773#file-typo3_flow_resource_resourcemanager-php-L480
Possible reason¶
So, looks like the reason is at \TYPO3\Flow\Object\DependencyInjection\ProxyClassBuilder::buildPropertyInjectionCodeByConfiguration
. There is a check for
if ($propertyClassName === NULL) {
but at the end of the method, the $propertyClassName is still used without having been modified, hence still NULL:
1 protected function buildPropertyInjectionCodeByConfiguration(Configuration $objectConfiguration, $propertyName, Configuration $propertyConfiguration) {
2 $className = $objectConfiguration->getClassName();
3 $propertyClassName = $propertyConfiguration->getClassName();
4 if ($propertyClassName === NULL) {
5 $preparedSetterArgument = $this->buildCustomFactoryCall($propertyConfiguration->getFactoryObjectName(), $propertyConfiguration->getFactoryMethodName(), $propertyConfiguration->getArguments());
6 } else {
7 // ...
8 }
9 // ...
10 return $this->buildLazyPropertyInjectionCode($propertyClassName, $propertyName, $preparedSetterArgument);
11 }
See, obviously the last line can be invoked if $propertyClassName is NULL; which is quite often the case when using configured factories.
History
#1 Updated by Adrian Föder over 2 years ago
- Subject changed from Infinite recursive call in DependencyProxy to Empty class names in cache-related proxy classes
- Status changed from Accepted to New
- Priority changed from Must have to Should have
#2 Updated by Adrian Föder over 2 years ago
- Subject changed from Empty class names in cache-related proxy classes to Empty class names in DependencyInjection proxy code when using Caches / Factory-created dependencies
#3 Updated by Adrian Föder over 2 years ago
- Priority changed from Should have to Must have
#4 Updated by Robert Lemke about 2 years ago
- Assigned To deleted (
Robert Lemke) - Target version set to 2.0.1