Bug #54275
closed
ClassLoader creates additional cacheidentifier for same file
Added by Stefan Froemken almost 11 years ago.
Updated about 7 years ago.
Description
Hello Core-Team,
I get following error message on my Mac with MAMP PRO:
PHP Fatal error: Cannot redeclare class SF\Sfcategory\Domain\Model\Car in /Applications/MAMP/htdocs/typo3_git/typo3conf/ext/sfcategory/Classes/domain/model/car.php on line 87
My extension uses Namespaces. So I have a cache entry: sf_sfcategory_domain_model_car in Cache/Data/cache_classes
But while mapping the data into Model through DataMapper Extbase tries to create a classname from tablename. On that way a classname tx_sfcategory_domain_model_car was created. So I have two entries in my cache_classes-directory with the same classpath.
Further sf_sfcategory_domain_model_car contains an ucfirst path: Classes/Domain/Model/Car.php
But tx_sfcategory_domain_model_car has following path: Classes/domain/model/car.php
Stefan
@Tom,@Ernesto: Maybe this is an issue worth noting?
As a workaround:
Create following file: typo3conf/ext/[ExtKey]/Migrations/Code/ClassAliasMap.php
with a mapping array, how to map old classnames to new namespaced classes:
<?php
return array(
'tx_clubdirectory_domain_model_club' => 'JWeiland\\Clubdirectory\\Domain\\Model\\Club',
'tx_clubdirectory_domain_model_address' => 'JWeiland\\Clubdirectory\\Domain\\Model\\Address',
'tx_clubdirectory_domain_model_district' => 'JWeiland\\Clubdirectory\\Domain\\Model\\District'
);
Now DataMapper knows where to map Array-data into.
Stefan
- Assignee set to Thomas Maroschik
Hello Core-Team,
I have debugged this issue a little bit deeper. This problem exists if you work with probertyName=tablenames. sys_category is a good example.
In Typo3DbBackend->parseComparison() you have a call to getPlainValue(). In my case this value is "tx_sfcategory_domain_model_car". So in getPlainValue you have added the new TypeHandlingUtility::isCoreType. This method now tries to require_once this className and sure...it is a valid className. But this check creates a new and wrong ClassesCacheEntry: tx_sfcategory_domain_model_car.
isCoreType should never be called if propertyName is "tablenames" or do you have a better idea how to prevent checking this tablename through ClassLoader?!
Stefan
- Status changed from New to Under Review
Gerrit Code Review wrote:
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27079
This fixes the Extbase part by changing gePlainValue to not trigger the class loader.
But I think the class loader should also be fixed to not load classes like "\Vendor\Ext\Foo\Bar" when class "tx_ext_foo_bar" is requested to be loaded.
- Assignee changed from Thomas Maroschik to Helmut Hummel
Stefan Froemken wrote:
Hello Core-Team,
I get following error message on my Mac with MAMP PRO:
PHP Fatal error: Cannot redeclare class SF\Sfcategory\Domain\Model\Car in /Applications/MAMP/htdocs/typo3_git/typo3conf/ext/sfcategory/Classes/domain/model/car.php on line 87
Can you check if my WIP change fixes your problem?
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
- Status changed from Resolved to Closed
Also available in: Atom
PDF