Search code examples
cachingmappingtypo3typo3-7.6.xtypo3-extensions

How to avoid TYPO3 caching of table mapping for the whole multi website installation?


I have one TYPO3 installation 7.6.22 with different websites, each in own page trees.

In an own extension normally a certain object is persisted in table tx_myextension_domain_model_name.

But for one website A I need to map this object on another table A. So I defined the typoscript config.tx_extbase.persistence.classes.MyVendor\Myextension\Domain\Model\Name.mapping ... in a separate extension especially for this website A.

This works but its not possible at the moment to have both mappings parallel.

If I - after clearing all caches - load the plugin in the frontend of website A, all other websites have the mapping on table A (and not on tx_myextension_domain_model_name).

If I - after clearing all caches - load the plugin in the frontend of one of the other websites, everything is ok on this website, but website A produces an error, because some processes doesn't work with the default table tx_myextension_domain_model_name.

So obviously somewhere the mapping configuration is cached for the whole installation, not on a per website base. Is that a bug or a feature? And is there a way to work around?


Solution

  • Take a look at this issue in TYPO3 forge and my comment at the very bottom.

    https://forge.typo3.org/issues/75399#change-337355

    Clearly: You need to disable the property mapper cache. In your AdditionalConfiguration.php file add the following.

    $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap']['backend'] = 'TYPO3\CMS\Core\Cache\Backend\NullBackend';
    

    This will cost you probably some performance, but I do not think it will be that much. But you will be able to configure different mappings for different sites using (local) TypoScript setup.