diff --git a/.gitignore b/.gitignore
index 6660c1581d2..7bc67772cd5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,11 +18,6 @@
/source/export/*
!/source/export/.gitkeep
-# Temporary files
-!/source/tmp/
-/source/tmp/*
-!/source/tmp/.htaccess
-
# Composer
/vendor/
/composer.lock
diff --git a/CHANGELOG-8.0.md b/CHANGELOG-8.0.md
index 7c5cb4a53c4..e268250eb87 100644
--- a/CHANGELOG-8.0.md
+++ b/CHANGELOG-8.0.md
@@ -3,20 +3,30 @@
## v8.0.0 - unreleased
### Added
+
- Set custom product low stock label [#0004401](https://bugs.oxid-esales.com/view.php?id=4401)
+- Support PSR caching interface and related functionalities and applied them on module cache.
### Changed
-- Admin directory is not removed from the url in `ViewConfig::getModuleUrl` anymore [PR-817](https://github.com/OXID-eSales/oxideshop_ce/pull/817)
-- Reset created product "sold" counter during Copying of the product [PR-913](https://github.com/OXID-eSales/oxideshop_ce/pull/913)
+
+- Admin directory is not removed from the url in `ViewConfig::getModuleUrl`
+ anymore [PR-817](https://github.com/OXID-eSales/oxideshop_ce/pull/817)
+- Reset created product "sold" counter during Copying of the
+ product [PR-913](https://github.com/OXID-eSales/oxideshop_ce/pull/913)
- `ModuleConfigurationValidatorInterface` is not optional anymore in the module activation service.
-- The visibility of time-activated products has changed, products with an undefined end date appear in the shop for an unlimited period of time
+- The visibility of time-activated products has changed, products with an undefined end date appear in the shop for an
+ unlimited period of time
### Removed
-- Remove console classes from the Internal namespace: `Executor`, `ExecutorInterface`, `CommandsProvider`, `CommandsProviderInterface`
+
+- Remove console classes from the Internal
+ namespace: `Executor`, `ExecutorInterface`, `CommandsProvider`, `CommandsProviderInterface`
- Cleanup deprecated Private Sales Invite functionality
- `getContainer()` and `dispatchEvent()` methods from Core classes
- Remove deprecated global function \makeReadable()
- Redundant `TemplateFileResolverInterface` functionality
- Smarty templates support
-- `PAYMENT_INFO_OFF` translation [#0006426](https://bugs.oxid-esales.com/view.php?id=6426) [PR-953](https://github.com/OXID-eSales/oxideshop_ce/pull/953)
+- `PAYMENT_INFO_OFF`
+ translation [#0006426](https://bugs.oxid-esales.com/view.php?id=6426) [PR-953](https://github.com/OXID-eSales/oxideshop_ce/pull/953)
- Remove deprecated `TemplateCacheService` implementation
+- Obsolete caching related functionalities
\ No newline at end of file
diff --git a/source/Internal/Framework/Cache/Command/ClearCacheCommand.php b/source/Internal/Framework/Cache/Command/ClearCacheCommand.php
index cbaaf40a13f..79f2b43b5e5 100644
--- a/source/Internal/Framework/Cache/Command/ClearCacheCommand.php
+++ b/source/Internal/Framework/Cache/Command/ClearCacheCommand.php
@@ -1,13 +1,16 @@
shopTemplateCacheService->invalidateAllShopsCache();
- $this->shopAdapter->invalidateModulesCache();
-
+ $this->shopCacheCleaner->clearAll();
foreach ($this->context->getAllShopIds() as $shopId) {
$this->containerCache->invalidate($shopId);
}
-
- $this->moduleCacheService->invalidateAll();
-
- $output->writeln("Cleared cache files");
+ $output->writeln('Cleared cache files');
return 0;
}
diff --git a/source/Internal/Framework/Cache/Pool/CacheItemPoolFactoryInterface.php b/source/Internal/Framework/Cache/Pool/CacheItemPoolFactoryInterface.php
new file mode 100644
index 00000000000..88c032642be
--- /dev/null
+++ b/source/Internal/Framework/Cache/Pool/CacheItemPoolFactoryInterface.php
@@ -0,0 +1,15 @@
+context->getCacheDirectory(), 'pool',)
+ );
+ }
+}
diff --git a/source/Internal/Framework/Cache/Pool/services.yaml b/source/Internal/Framework/Cache/Pool/services.yaml
new file mode 100644
index 00000000000..c950dc4151e
--- /dev/null
+++ b/source/Internal/Framework/Cache/Pool/services.yaml
@@ -0,0 +1,10 @@
+services:
+ _defaults:
+ autowire: true
+
+ OxidEsales\EshopCommunity\Internal\Framework\Cache\Pool\CacheItemPoolFactoryInterface:
+ class: OxidEsales\EshopCommunity\Internal\Framework\Cache\Pool\FilesystemCacheItemPoolFactory
+
+ Psr\Cache\CacheItemPoolInterface:
+ factory: ['@OxidEsales\EshopCommunity\Internal\Framework\Cache\Pool\CacheItemPoolFactoryInterface', 'create']
+ arguments: ['@=service("OxidEsales\\EshopCommunity\\Internal\\Transition\\Utility\\ContextInterface").getCurrentShopId()']
diff --git a/source/Internal/Framework/Cache/ShopCacheCleanerInterface.php b/source/Internal/Framework/Cache/ShopCacheCleanerInterface.php
new file mode 100644
index 00000000000..be9700d3f49
--- /dev/null
+++ b/source/Internal/Framework/Cache/ShopCacheCleanerInterface.php
@@ -0,0 +1,15 @@
+shopAdapter->invalidateModulesCache();
+ $this->templateCacheService->invalidateCache($shopId);
+ $this->cacheItemPoolFactory->create($shopId)->clear();
+ }
+
+ public function clearAll(): void
+ {
+ $this->shopAdapter->invalidateModulesCache();
+ $this->templateCacheService->invalidateAllShopsCache();
+ foreach ($this->context->getAllShopIds() as $shopId) {
+ $this->cacheItemPoolFactory->create($shopId)->clear();
+ }
+ }
+}
diff --git a/source/Internal/Framework/Cache/services.yaml b/source/Internal/Framework/Cache/services.yaml
index f61fb4d09e6..f3645607201 100644
--- a/source/Internal/Framework/Cache/services.yaml
+++ b/source/Internal/Framework/Cache/services.yaml
@@ -1,2 +1,11 @@
imports:
- - { resource: Command/services.yaml }
\ No newline at end of file
+ - { resource: Pool/services.yaml }
+ - { resource: Command/services.yaml }
+
+services:
+ _defaults:
+ autowire: true
+
+ OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface:
+ class: OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheFacade
+ public: true
diff --git a/source/Internal/Framework/DIContainer/ContainerBuilder.php b/source/Internal/Framework/DIContainer/ContainerBuilder.php
index 0462dfb27a7..4c86d9a937e 100644
--- a/source/Internal/Framework/DIContainer/ContainerBuilder.php
+++ b/source/Internal/Framework/DIContainer/ContainerBuilder.php
@@ -39,6 +39,9 @@ public function getContainer(): SymfonyContainerBuilder
$symfonyContainer = new SymfonyContainerBuilder();
$symfonyContainer->addCompilerPass(new RegisterListenersPass());
$symfonyContainer->addCompilerPass(new AddConsoleCommandPass());
+
+ $symfonyContainer->setParameter('oxid_cache_directory', $this->context->getCacheDirectory());
+
$this->loadEditionServices($symfonyContainer);
$this->loadModuleServices($symfonyContainer);
$this->loadProjectServices($symfonyContainer);
@@ -115,13 +118,13 @@ private function loadModuleServices(SymfonyContainerBuilder $symfonyContainer):
//no active modules, do nothing.
} catch (LoaderLoadException $exception) {
$loggerServiceFactory = new LoggerServiceFactory(new Context());
- $logger = $loggerServiceFactory->getLogger();
- // phpcs:disable
- $logger->error(
- "Can't load module services file path $moduleServicesFilePath. Please check if file exists and all imports in the file are correct.",
- [$exception]
- );
- // phpcs:enable
+ $loggerServiceFactory
+ ->getLogger()
+ ->error(
+ "Can't load module services file path $moduleServicesFilePath.
+ Please check if file exists and all imports in the file are correct.",
+ [$exception]
+ );
}
}
diff --git a/source/Internal/Framework/Module/Cache/FilesystemModuleCache.php b/source/Internal/Framework/Module/Cache/FilesystemModuleCache.php
deleted file mode 100644
index c039aa8e514..00000000000
--- a/source/Internal/Framework/Module/Cache/FilesystemModuleCache.php
+++ /dev/null
@@ -1,150 +0,0 @@
-shopTemplateCacheService->invalidateCache($shopId);
- $this->shopAdapter->invalidateModuleCache($moduleId);
- $this->fileSystem->remove($this->getShopModulePathCacheDirectory($shopId));
- }
-
- public function invalidateAll(): void
- {
- $this->shopTemplateCacheService->invalidateAllShopsCache();
- $this->shopAdapter->invalidateModulesCache();
-
- $templateCacheDirectory = $this->basicContext->getModuleCacheDirectory();
- if ($this->fileSystem->exists($templateCacheDirectory)) {
- $recursiveIterator = new RecursiveIteratorIterator(
- new RecursiveDirectoryIterator($templateCacheDirectory, FilesystemIterator::SKIP_DOTS),
- RecursiveIteratorIterator::SELF_FIRST,
- RecursiveIteratorIterator::CATCH_GET_CHILD
- );
- $this->fileSystem->remove($recursiveIterator);
- }
- }
-
- /**
- * @param string $key
- * @param int $shopId
- * @param array $data
- */
- public function put(string $key, int $shopId, array $data): void
- {
- $this->fileSystem->dumpFile(
- $this->getModulePathCacheFilePath($key, $shopId),
- $this->encode($data)
- );
- }
-
- /**
- * @param string $key
- * @param int $shopId
- *
- * @return array
- * @throws CacheNotFoundException
- */
- public function get(string $key, int $shopId): array
- {
- if (!$this->exists($key, $shopId)) {
- throw new CacheNotFoundException("Cache with key '$key' for the shop with id $shopId not found.");
- }
-
- return $this->getCacheFileContent($this->getModulePathCacheFilePath($key, $shopId));
- }
-
- /**
- * @param string $key
- * @param int $shopId
- *
- * @return bool
- */
- public function exists(string $key, int $shopId): bool
- {
- return $this->fileSystem->exists($this->getModulePathCacheFilePath($key, $shopId));
- }
-
- private function getCacheFileContent(string $modulePathCacheFilePath): array
- {
- return $this->decode(
- file_get_contents($modulePathCacheFilePath)
- );
- }
-
- private function getModulePathCacheFilePath(string $key, int $shopId): string
- {
- return Path::join(
- $this->getShopModulePathCacheDirectory($shopId),
- $key . '.txt'
- );
- }
-
- private function getShopModulePathCacheDirectory(int $shopId): string
- {
- return Path::join(
- $this->basicContext->getModuleCacheDirectory(),
- (string)$shopId
- );
- }
-
- /**
- * @param array $data
- *
- * @return string
- * @throws \JsonException
- */
- private function encode(array $data): string
- {
- return json_encode($data, JSON_THROW_ON_ERROR);
- }
-
- /**
- * @param string $data
- *
- * @return mixed
- * @throws \JsonException
- */
- private function decode(string $data): mixed
- {
- return json_decode(
- $data,
- true,
- 512,
- JSON_THROW_ON_ERROR
- );
- }
-}
diff --git a/source/Internal/Framework/Module/Cache/FilesystemModuleCacheBridge.php b/source/Internal/Framework/Module/Cache/FilesystemModuleCacheBridge.php
deleted file mode 100644
index 4d907ee73db..00000000000
--- a/source/Internal/Framework/Module/Cache/FilesystemModuleCacheBridge.php
+++ /dev/null
@@ -1,23 +0,0 @@
-moduleCacheService->invalidateAll();
- }
-}
diff --git a/source/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriber.php b/source/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriber.php
index 11a53311e6b..c0b7e8e0b00 100644
--- a/source/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriber.php
+++ b/source/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriber.php
@@ -9,6 +9,7 @@
namespace OxidEsales\EshopCommunity\Internal\Framework\Module\Cache;
+use OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Event\ModuleConfigurationChangedEvent;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Event\FinalizingModuleActivationEvent;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Event\FinalizingModuleDeactivationEvent;
@@ -17,14 +18,13 @@
class InvalidateModuleCacheEventSubscriber implements EventSubscriberInterface
{
- public function __construct(private ModuleCacheServiceInterface $moduleCacheService)
+ public function __construct(private readonly ShopCacheCleanerInterface $shopCacheCleaner)
{
}
- public function invalidateModuleCache(
- ModuleSetupEvent|ModuleConfigurationChangedEvent $event
- ): void {
- $this->moduleCacheService->invalidate($event->getModuleId(), $event->getShopId());
+ public function invalidateModuleCache(ModuleSetupEvent|ModuleConfigurationChangedEvent $event): void
+ {
+ $this->shopCacheCleaner->clear($event->getShopId());
}
public static function getSubscribedEvents(): array
@@ -32,7 +32,7 @@ public static function getSubscribedEvents(): array
return [
FinalizingModuleActivationEvent::class => 'invalidateModuleCache',
FinalizingModuleDeactivationEvent::class => 'invalidateModuleCache',
- ModuleConfigurationChangedEvent::class => 'invalidateModuleCache',
+ ModuleConfigurationChangedEvent::class => 'invalidateModuleCache',
];
}
}
diff --git a/source/Internal/Framework/Module/Cache/ModuleCache.php b/source/Internal/Framework/Module/Cache/ModuleCache.php
new file mode 100644
index 00000000000..68187e92bfc
--- /dev/null
+++ b/source/Internal/Framework/Module/Cache/ModuleCache.php
@@ -0,0 +1,50 @@
+cache->deleteItem($key);
+ }
+
+ public function put(string $key, array $data): void
+ {
+ $cacheItem = $this->cache->getItem($key);
+ $cacheItem->set($data);
+ $this->cache->save($cacheItem);
+ }
+
+ /**
+ * @throws CacheNotFoundException
+ */
+ public function get(string $key): array
+ {
+ $cacheItem = $this->cache->getItem($key);
+
+ if (!$cacheItem->isHit()) {
+ throw new CacheNotFoundException("Cache with key '$key' not found.");
+ }
+
+ return $cacheItem->get();
+ }
+
+ public function exists(string $key): bool
+ {
+ return $this->cache->getItem($key)->isHit();
+ }
+}
diff --git a/source/Internal/Framework/Module/Cache/ModuleCacheInterface.php b/source/Internal/Framework/Module/Cache/ModuleCacheInterface.php
new file mode 100644
index 00000000000..cf56a1616f9
--- /dev/null
+++ b/source/Internal/Framework/Module/Cache/ModuleCacheInterface.php
@@ -0,0 +1,19 @@
+context->getCurrentShopId();
$cacheKey = 'absolute_module_paths';
- if (!$this->moduleCacheService->exists($cacheKey, $shopId)) {
- $this->moduleCacheService->put(
+ if (!$this->moduleCache->exists($cacheKey)) {
+ $this->moduleCache->put(
$cacheKey,
- $shopId,
$this->collectModulePathsForCaching()
);
}
- return $this->moduleCacheService->get($cacheKey, $shopId);
+ return $this->moduleCache->get($cacheKey);
}
/** @inheritDoc */
public function getControllers(): array
{
- $shopId = $this->context->getCurrentShopId();
$cacheKey = 'controllers';
- if (!$this->moduleCacheService->exists($cacheKey, $shopId)) {
- $this->moduleCacheService->put($cacheKey, $shopId, $this->collectControllersForCaching());
+ if (!$this->moduleCache->exists($cacheKey)) {
+ $this->moduleCache->put($cacheKey, $this->collectControllersForCaching());
}
return $this->createControllersFromData(
- $this->moduleCacheService->get($cacheKey, $shopId)
+ $this->moduleCache->get($cacheKey)
);
}
@@ -76,15 +73,14 @@ public function getClassExtensions(): array
$shopId = $this->context->getCurrentShopId();
$cacheKey = 'module_class_extensions';
- if (!$this->moduleCacheService->exists($cacheKey, $shopId)) {
- $this->moduleCacheService->put(
+ if (!$this->moduleCache->exists($cacheKey)) {
+ $this->moduleCache->put(
$cacheKey,
- $shopId,
$this->activeClassExtensionChainResolver->getActiveExtensionChain($shopId)->getChain()
);
}
- return $this->moduleCacheService->get($cacheKey, $shopId);
+ return $this->moduleCache->get($cacheKey);
}
/** @return array */
diff --git a/source/Internal/Framework/Module/Facade/ModuleSettingService.php b/source/Internal/Framework/Module/Facade/ModuleSettingService.php
index 7f94b93234b..d02c7497705 100644
--- a/source/Internal/Framework/Module/Facade/ModuleSettingService.php
+++ b/source/Internal/Framework/Module/Facade/ModuleSettingService.php
@@ -9,7 +9,7 @@
namespace OxidEsales\EshopCommunity\Internal\Framework\Module\Facade;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
+use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ModuleConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Event\SettingChangedEvent;
@@ -20,10 +20,10 @@
class ModuleSettingService implements ModuleSettingServiceInterface
{
public function __construct(
- private ContextInterface $context,
- private ModuleConfigurationDaoInterface $moduleConfigurationDao,
- private ModuleCacheServiceInterface $moduleCacheService,
- private EventDispatcherInterface $eventDispatcher
+ private readonly ContextInterface $context,
+ private readonly ModuleConfigurationDaoInterface $moduleConfigurationDao,
+ private readonly ModuleCacheInterface $moduleCache,
+ private readonly EventDispatcherInterface $eventDispatcher
) {
}
@@ -92,8 +92,6 @@ private function saveSettingToModuleConfiguration(string $moduleId, string $name
{
$shopId = $this->context->getCurrentShopId();
- $this->moduleCacheService->invalidate($moduleId, $shopId);
-
$moduleConfiguration = $this->moduleConfigurationDao->get($moduleId, $shopId);
$setting = $moduleConfiguration->getModuleSetting($name);
$setting->setValue($value);
@@ -107,15 +105,14 @@ private function getValue(string $moduleId, string $name): mixed
$shopId = $this->context->getCurrentShopId();
$cacheKey = $this->getCacheKey($moduleId, $name);
- if (!$this->moduleCacheService->exists($cacheKey, $shopId)) {
- $this->moduleCacheService->put(
+ if (!$this->moduleCache->exists($cacheKey)) {
+ $this->moduleCache->put(
$cacheKey,
- $shopId,
['value' => $this->moduleConfigurationDao->get($moduleId, $shopId)->getModuleSetting($name)->getValue()]
);
}
- return $this->moduleCacheService->get($cacheKey, $shopId)['value'];
+ return $this->moduleCache->get($cacheKey, $shopId)['value'];
}
private function getCacheKey(string $moduleId, string $name): string
diff --git a/source/Internal/Framework/Theme/Command/ThemeActivateCommand.php b/source/Internal/Framework/Theme/Command/ThemeActivateCommand.php
index e8750c18d67..a254adf6993 100644
--- a/source/Internal/Framework/Theme/Command/ThemeActivateCommand.php
+++ b/source/Internal/Framework/Theme/Command/ThemeActivateCommand.php
@@ -9,8 +9,7 @@
namespace OxidEsales\EshopCommunity\Internal\Framework\Theme\Command;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
-use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface;
+use OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\ShopAdapterInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -25,8 +24,7 @@ class ThemeActivateCommand extends Command
public function __construct(
private readonly ShopAdapterInterface $shopAdapter,
- private readonly ShopTemplateCacheServiceInterface $shopTemplateCacheService,
- private readonly ModuleCacheServiceInterface $moduleCacheService
+ private readonly ShopCacheCleanerInterface $shopCacheCleaner,
) {
parent::__construct();
}
@@ -57,8 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$this->shopAdapter->activateTheme($themeId);
- $this->moduleCacheService->invalidateAll();
- $this->shopTemplateCacheService->invalidateAllShopsCache();
+ $this->shopCacheCleaner->clearAll();
$output->writeLn('' . sprintf(self::MESSAGE_THEME_ACTIVATED, $themeId) . '');
return Command::SUCCESS;
diff --git a/source/Internal/Transition/Utility/BasicContext.php b/source/Internal/Transition/Utility/BasicContext.php
index 78ca4ca1f4f..0b827123342 100644
--- a/source/Internal/Transition/Utility/BasicContext.php
+++ b/source/Internal/Transition/Utility/BasicContext.php
@@ -30,25 +30,16 @@ class BasicContext implements BasicContextInterface
*/
private $facts;
- /**
- * @return string
- */
public function getContainerCacheFilePath(int $shopId): string
{
return Path::join($this->getCacheDirectory(), 'container', 'container_cache_shop_' . $shopId . '.php');
}
- /**
- * @return string
- */
public function getGeneratedServicesFilePath(): string
{
return Path::join($this->getShopRootPath(), 'var', 'generated', 'generated_services.yaml');
}
- /**
- * @return string
- */
public function getConfigurableServicesFilePath(): string
{
return Path::join($this->getShopRootPath(), 'var', 'configuration', 'configurable_services.yaml');
@@ -67,66 +58,41 @@ public function getActiveModuleServicesFilePath(int $shopId): string
return Path::join($this->getShopConfigurationDirectory($shopId), 'active_module_services.yaml');
}
- /**
- * @return string
- */
public function getSourcePath(): string
{
return $this->getFacts()->getSourcePath();
}
- /**
- * @return string
- * @throws \Exception
- */
public function getEdition(): string
{
return $this->getFacts()->getEdition();
}
- /**
- * @return string
- */
public function getCommunityEditionSourcePath(): string
{
return $this->getFacts()->getCommunityEditionSourcePath();
}
- /**
- * @return string
- */
public function getProfessionalEditionRootPath(): string
{
return $this->getFacts()->getProfessionalEditionRootPath();
}
- /**
- * @return string
- */
public function getOutPath(): string
{
return $this->getFacts()->getOutPath();
}
- /**
- * @return string
- */
public function getEnterpriseEditionRootPath(): string
{
return $this->getFacts()->getEnterpriseEditionRootPath();
}
- /**
- * @return int
- */
public function getDefaultShopId(): int
{
return ShopIdCalculator::BASE_SHOP_ID;
}
- /**
- * @return array
- */
public function getAllShopIds(): array
{
return [
@@ -134,84 +100,57 @@ public function getAllShopIds(): array
];
}
- /**
- * @return array
- */
public function getBackwardsCompatibilityClassMap(): array
{
return (new BackwardsCompatibilityClassMapProvider())->getMap();
}
- /**
- * @return string
- */
public function getProjectConfigurationDirectory(): string
{
return $this->getConfigurationDirectoryPath();
}
- /**
- * @return string
- */
public function getConfigurationDirectoryPath(): string
{
return $this->getShopRootPath() . '/var/configuration/';
}
- /**
- * @return string
- */
public function getShopConfigurationDirectory(int $shopId): string
{
- return Path::join($this->getProjectConfigurationDirectory(), 'shops', (string) $shopId);
+ return Path::join($this->getProjectConfigurationDirectory(), 'shops', (string)$shopId);
}
- /**
- * @return string
- */
public function getShopRootPath(): string
{
return $this->getFacts()->getShopRootPath();
}
- /**
- * @return string
- */
public function getVendorPath(): string
{
return $this->getFacts()->getVendorPath();
}
- /**
- * @return string
- */
public function getComposerVendorName(): string
{
return $this->getFacts()::COMPOSER_VENDOR_OXID_ESALES;
}
- /**
- * @return string
- */
public function getConfigFilePath(): string
{
return $this->getSourcePath() . '/config.inc.php';
}
- /**
- * @return string
- */
public function getConfigTableName(): string
{
return 'oxconfig';
}
- /**
- * @return string
- */
public function getCacheDirectory(): string
{
- return (new ConfigFile())->getVar('sCompileDir');
+ return Path::join(
+ (new ConfigFile())->getVar('sCompileDir'),
+ 'cache'
+ );
}
public function getModuleCacheDirectory(): string
@@ -222,9 +161,6 @@ public function getModuleCacheDirectory(): string
);
}
- /**
- * @return Facts
- */
public function getFacts(): Facts
{
if ($this->facts === null) {
diff --git a/source/tmp/.htaccess b/source/tmp/.htaccess
deleted file mode 100644
index 52374767d4e..00000000000
--- a/source/tmp/.htaccess
+++ /dev/null
@@ -1,12 +0,0 @@
-# disabling file access
-
-
- Require all denied
-
-
- Order allow,deny
- Deny from all
-
-
-
-Options -Indexes
diff --git a/tests/Integration/Core/ModuleVariablesLocatorTest.php b/tests/Integration/Core/ModuleVariablesLocatorTest.php
index 7b140c1c1ad..a8d95597a1b 100644
--- a/tests/Integration/Core/ModuleVariablesLocatorTest.php
+++ b/tests/Integration/Core/ModuleVariablesLocatorTest.php
@@ -14,7 +14,7 @@
use OxidEsales\Eshop\Core\ShopIdCalculator;
use OxidEsales\EshopCommunity\Core\SubShopSpecificFileCache;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
+use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheInterface;
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;
use PHPUnit\Framework\Attributes\Group;
@@ -72,15 +72,13 @@ private function switchShop(int $shopId): void
private function putChainToCache(array $chain): void
{
- $shopId = 1;
$cacheKey = 'module_class_extensions';
ContainerFactory::getInstance()
->getContainer()
- ->get(ModuleCacheServiceInterface::class)
+ ->get(ModuleCacheInterface::class)
->put(
$cacheKey,
- $shopId,
$chain
);
}
diff --git a/tests/Integration/Internal/Container/ContainerBuilderTest.php b/tests/Integration/Internal/Container/ContainerBuilderTest.php
index a04c6d335f5..f1f23ef2929 100644
--- a/tests/Integration/Internal/Container/ContainerBuilderTest.php
+++ b/tests/Integration/Internal/Container/ContainerBuilderTest.php
@@ -14,10 +14,11 @@
use OxidEsales\EshopCommunity\Tests\Unit\Internal\BasicContextStub;
use OxidEsales\EshopCommunity\Tests\Unit\Internal\ContextStub;
use OxidEsales\Facts\Edition\EditionSelector;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Container;
-class ContainerBuilderTest extends TestCase
+final class ContainerBuilderTest extends TestCase
{
public function testWhenCeServicesLoaded(): void
{
@@ -102,6 +103,19 @@ public function testWhenShopRelatedConfigOverwritesMainServices(): void
);
}
+ #[Group('cache')]
+ public function testCacheDirectoryParameterIsSet(): void
+ {
+ $context = $this->makeContextStub();
+ $context->setCacheDirectory('cache');
+ $container = $this->makeContainer($context);
+
+ $this->assertSame(
+ $context->getCacheDirectory(),
+ $container->getParameter('oxid_cache_directory')
+ );
+ }
+
private function makeContainer(BasicContextInterface $context): Container
{
$containerBuilder = new ContainerBuilder($context);
diff --git a/tests/Integration/Internal/Framework/Cache/ShopCacheFacadeTest.php b/tests/Integration/Internal/Framework/Cache/ShopCacheFacadeTest.php
new file mode 100644
index 00000000000..2e481091911
--- /dev/null
+++ b/tests/Integration/Internal/Framework/Cache/ShopCacheFacadeTest.php
@@ -0,0 +1,45 @@
+getModuleCache();
+ $moduleCache->put('test', ['something']);
+
+ $shopPool = $this->getShopCacheCleaner();
+ $shopPool->clear(1);
+
+ $this->assertFalse(
+ $moduleCache->exists('test')
+ );
+ }
+
+ private function getShopCacheCleaner(): ShopCacheCleanerInterface
+ {
+ return $this->get(ShopCacheCleanerInterface::class);
+ }
+
+ private function getModuleCache(): ModuleCacheInterface
+ {
+ return $this->get(ModuleCacheInterface::class);
+ }
+}
diff --git a/tests/Integration/Internal/Framework/Module/Cache/FilesystemModuleCacheTest.php b/tests/Integration/Internal/Framework/Module/Cache/ModuleCacheTest.php
similarity index 54%
rename from tests/Integration/Internal/Framework/Module/Cache/FilesystemModuleCacheTest.php
rename to tests/Integration/Internal/Framework/Module/Cache/ModuleCacheTest.php
index 053f33067ed..f1cecc9cba4 100644
--- a/tests/Integration/Internal/Framework/Module/Cache/FilesystemModuleCacheTest.php
+++ b/tests/Integration/Internal/Framework/Module/Cache/ModuleCacheTest.php
@@ -10,60 +10,46 @@
namespace OxidEsales\EshopCommunity\Tests\Integration\Internal\Framework\Module\Cache;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\CacheNotFoundException;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
+use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheInterface;
use OxidEsales\EshopCommunity\Tests\ContainerTrait;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
-final class FilesystemModuleCacheTest extends TestCase
+#[Group('cache')]
+final class ModuleCacheTest extends TestCase
{
use ContainerTrait;
public function testPut(): void
{
$cache = $this->getModuleCacheService();
- $cache->put('test', 1, ['something']);
+ $cache->put('test', ['something']);
$this->assertEquals(
['something'],
- $cache->get('test', 1)
+ $cache->get('test')
);
}
public function testExists(): void
{
$cache = $this->getModuleCacheService();
- $cache->put('test', 1, ['something']);
+ $cache->put('test', ['something']);
$this->assertTrue(
- $cache->exists('test', 1)
+ $cache->exists('test')
);
}
public function testInvalidate(): void
{
$cache = $this->getModuleCacheService();
- $cache->put('test', 1, ['something']);
+ $cache->put('test_key', ['something']);
- $cache->invalidate('someModule', 1);
+ $cache->deleteItem('test_key');
$this->assertFalse(
- $cache->exists('test', 1)
- );
- }
-
- public function testInvalidateAll(): void
- {
- $cache = $this->getModuleCacheService();
- $cache->put('test', 1, ['something']);
- $cache->put('test2', 2, ['something']);
-
- $cache->invalidateAll();
-
- $this->assertFalse(
- $cache->exists('test', 1)
- );
- $this->assertFalse(
- $cache->exists('test2', 2)
+ $cache->exists('test_key')
);
}
@@ -72,11 +58,11 @@ public function testGetNotExistentCache(): void
$cache = $this->getModuleCacheService();
$this->expectException(CacheNotFoundException::class);
- $cache->get('nonExistent', 1);
+ $cache->get('nonExistent');
}
- private function getModuleCacheService(): ModuleCacheServiceInterface
+ private function getModuleCacheService(): ModuleCacheInterface
{
- return $this->get(ModuleCacheServiceInterface::class);
+ return $this->get(ModuleCacheInterface::class);
}
}
diff --git a/tests/Integration/Internal/Framework/Module/Facade/ActiveModulesDataProviderTest.php b/tests/Integration/Internal/Framework/Module/Facade/ActiveModulesDataProviderTest.php
index 205878ab76c..ba9a789ad4c 100644
--- a/tests/Integration/Internal/Framework/Module/Facade/ActiveModulesDataProviderTest.php
+++ b/tests/Integration/Internal/Framework/Module/Facade/ActiveModulesDataProviderTest.php
@@ -7,9 +7,9 @@
declare(strict_types=1);
-namespace Integration\Internal\Framework\Module\Facade;
+namespace OxidEsales\EshopCommunity\Tests\Integration\Internal\Framework\Module\Facade;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
+use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ModuleConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ShopConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ClassExtensionsChain;
@@ -22,6 +22,7 @@
use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContext;
use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface;
use OxidEsales\EshopCommunity\Tests\ContainerTrait;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Path;
@@ -71,10 +72,11 @@ public function testGetModulePathsWillReturnSourcePathForActiveModule(): void
);
}
+ #[Group('cache')]
public function testGetModulePathsUsesCacheIfItExists(): void
{
$cache = $this->getDummyCache();
- $cache->put('absolute_module_paths', 1, ['moduleId' => 'somePath']);
+ $cache->put('absolute_module_paths', ['moduleId' => 'somePath']);
$activeModulesDataProvider = $this->getActiveModulesDataProviderWithCache($cache);
@@ -98,7 +100,8 @@ public function testGetModulePathsUsesCacheIfItDoesNotExist(): void
public function testGetControllers(): void
{
- $activeModulesDataProvider = $this->getActiveModulesDataProviderWithCache($this->get(ModuleCacheServiceInterface::class));
+ $activeModulesDataProvider =
+ $this->getActiveModulesDataProviderWithCache($this->get(ModuleCacheInterface::class));
$this->assertEquals(
[
@@ -111,7 +114,8 @@ public function testGetControllers(): void
public function testGetModuleClassExtensionsIfCacheDoesNotExist(): void
{
- $activeModulesDataProvider = $this->getActiveModulesDataProviderWithCache($this->get(ModuleCacheServiceInterface::class));
+ $activeModulesDataProvider =
+ $this->getActiveModulesDataProviderWithCache($this->get(ModuleCacheInterface::class));
$this->assertEquals(
[
@@ -127,7 +131,6 @@ public function testGetModuleClassExtensionsUsesCacheIfItExists(): void
$cache = $this->getDummyCache();
$cache->put(
'module_class_extensions',
- 1,
[
'shopClassCache' => ['moduleExtensionClassName1'],
'anotherShopClassCache' => ['moduleExtensionClassName2'],
@@ -154,10 +157,12 @@ private function prepareTestShopConfiguration(): void
->addController(new ModuleConfiguration\Controller('activeController1', 'activeControllerNamespace1'))
->addController(new ModuleConfiguration\Controller('activeController2', 'activeControllerNamespace2'))
->addClassExtension(new ModuleConfiguration\ClassExtension('shopClass', 'moduleExtensionClassName1'))
- ->addClassExtension(new ModuleConfiguration\ClassExtension(
- 'anotherShopClass',
- 'moduleExtensionClassName2'
- ));
+ ->addClassExtension(
+ new ModuleConfiguration\ClassExtension(
+ 'anotherShopClass',
+ 'moduleExtensionClassName2'
+ )
+ );
$chain = new ClassExtensionsChain();
$chain->addExtension(new ModuleConfiguration\ClassExtension('shopClass', 'moduleExtensionClassName1'));
@@ -193,7 +198,7 @@ private function cleanUpTestData(): void
->deactivate($this->activeModuleId, $this->context->getDefaultShopId());
}
- private function getActiveModulesDataProviderWithCache(ModuleCacheServiceInterface $cache): ActiveModulesDataProvider
+ private function getActiveModulesDataProviderWithCache(ModuleCacheInterface $cache): ActiveModulesDataProvider
{
return new ActiveModulesDataProvider(
$this->get(ModuleConfigurationDaoInterface::class),
@@ -204,32 +209,28 @@ private function getActiveModulesDataProviderWithCache(ModuleCacheServiceInterfa
);
}
- private function getDummyCache(): ModuleCacheServiceInterface
+ private function getDummyCache(): ModuleCacheInterface
{
- return new class implements ModuleCacheServiceInterface {
+ return new class implements ModuleCacheInterface {
private array $cache;
- public function invalidate(string $moduleId, int $shopId): void
+ public function deleteItem(string $key): void
{
}
- public function invalidateAll(): void
+ public function put(string $key, array $data): void
{
+ $this->cache[$key] = $data;
}
- public function put(string $key, int $shopId, array $data): void
+ public function get(string $key): array
{
- $this->cache[$shopId][$key] = $data;
+ return $this->cache[$key];
}
- public function get(string $key, int $shopId): array
+ public function exists(string $key): bool
{
- return $this->cache[$shopId][$key];
- }
-
- public function exists(string $key, int $shopId): bool
- {
- return isset($this->cache[$shopId][$key]);
+ return isset($this->cache[$key]);
}
};
}
diff --git a/tests/Integration/Internal/Framework/Module/Facade/ModuleSettingServiceTest.php b/tests/Integration/Internal/Framework/Module/Facade/ModuleSettingServiceTest.php
index ac8b46798cd..df4fc49217e 100644
--- a/tests/Integration/Internal/Framework/Module/Facade/ModuleSettingServiceTest.php
+++ b/tests/Integration/Internal/Framework/Module/Facade/ModuleSettingServiceTest.php
@@ -7,7 +7,7 @@
declare(strict_types=1);
-namespace Integration\Internal\Framework\Module\Facade;
+namespace OxidEsales\EshopCommunity\Tests\Integration\Internal\Framework\Module\Facade;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ModuleConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ShopConfigurationDaoInterface;
@@ -16,6 +16,7 @@
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting;
use OxidEsales\EshopCommunity\Tests\ContainerTrait;
use PHPUnit\Framework\TestCase;
+
use function Symfony\Component\String\u;
final class ModuleSettingServiceTest extends TestCase
@@ -51,7 +52,7 @@ public function testBoolean(): void
{
$this->settingFacade->saveBoolean('boolSetting', true, $this->testModuleId);
- $this->assertSame(true, $this->settingFacade->getBoolean('boolSetting', $this->testModuleId));
+ $this->assertTrue($this->settingFacade->getBoolean('boolSetting', $this->testModuleId));
}
public function testString(): void
diff --git a/tests/Integration/Legacy/Modules/BaseModuleTestCase.php b/tests/Integration/Legacy/Modules/BaseModuleTestCase.php
index 0f97b7e3611..66c41a5c035 100644
--- a/tests/Integration/Legacy/Modules/BaseModuleTestCase.php
+++ b/tests/Integration/Legacy/Modules/BaseModuleTestCase.php
@@ -13,7 +13,7 @@
use OxidEsales\Eshop\Core\Module\Module;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceBridgeInterface;
+use OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\DataObject\OxidEshopPackage;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\ModuleInstallerInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface;
@@ -42,7 +42,7 @@ public function tearDown(): void
->get('oxid_esales.module.install.service.launched_shop_project_configuration_generator')
->generate();
$this->getContainer()
- ->get(ModuleCacheServiceBridgeInterface::class)->invalidateAll();
+ ->get(ShopCacheCleanerInterface::class)->clearAll();
parent::tearDown();
}
diff --git a/tests/Unit/Internal/BasicContextStub.php b/tests/Unit/Internal/BasicContextStub.php
index 9c78ae24562..dd0feeb3aed 100644
--- a/tests/Unit/Internal/BasicContextStub.php
+++ b/tests/Unit/Internal/BasicContextStub.php
@@ -218,14 +218,14 @@ public function getComposerVendorName(): string
return $this->composerVendorName;
}
- public function setCacheDirectory(string $cacheDirectory): void
+ public function getCacheDirectory(): string
{
- $this->cacheDirectory = $cacheDirectory;
+ return $this->cacheDirectory;
}
- public function getCacheDirectory(): string
+ public function setCacheDirectory(string $cacheDirectory): void
{
- return $this->cacheDirectory;
+ $this->cacheDirectory = $cacheDirectory;
}
public function getModuleCacheDirectory(): string
diff --git a/tests/Unit/Internal/Framework/Cache/Command/ClearCacheCommandTest.php b/tests/Unit/Internal/Framework/Cache/Command/ClearCacheCommandTest.php
index adc77f14305..73c06b9f81e 100644
--- a/tests/Unit/Internal/Framework/Cache/Command/ClearCacheCommandTest.php
+++ b/tests/Unit/Internal/Framework/Cache/Command/ClearCacheCommandTest.php
@@ -10,45 +10,52 @@
namespace OxidEsales\EshopCommunity\Tests\Unit\Internal\Framework\Cache\Command;
use OxidEsales\EshopCommunity\Internal\Framework\Cache\Command\ClearCacheCommand;
+use OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface;
use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Service\ContainerCacheInterface;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
-use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface;
-use OxidEsales\EshopCommunity\Internal\Transition\Adapter\ShopAdapterInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-class ClearCacheCommandTest extends TestCase
+#[Group('cache')]
+final class ClearCacheCommandTest extends TestCase
{
public function testClearCacheTriggersRegularAndTemplatesCleaners(): void
{
- $shopAdapterMock = $this->createMock(ShopAdapterInterface::class);
- $shopAdapterMock->expects($this->once())->method('invalidateModulesCache');
+ $command = new ClearCacheCommand(
+ $this->getContainerCacheMock(),
+ $this->getContextMock(),
+ $this->getShopCacheCleanerMock()
+ );
- $shopTemplateCacheServiceMock = $this->createMock(ShopTemplateCacheServiceInterface::class);
- $shopTemplateCacheServiceMock->expects($this->once())->method('invalidateAllShopsCache');
+ $command->run(
+ $this->createMock(InputInterface::class),
+ $this->createMock(OutputInterface::class),
+ );
+ }
+ private function getContainerCacheMock(): ContainerCacheInterface
+ {
$containerCacheMock = $this->createMock(ContainerCacheInterface::class);
$containerCacheMock->expects($this->once())->method('invalidate');
- $moduleCacheServiceMock = $this->createMock(ModuleCacheServiceInterface::class);
- $moduleCacheServiceMock->expects($this->once())->method('invalidateAll');
+ return $containerCacheMock;
+ }
+ private function getContextMock(): ContextInterface
+ {
$contextMock = $this->createMock(ContextInterface::class);
$contextMock->expects($this->once())->method('getAllShopIds')->willReturn([1]);
- $command = new ClearCacheCommand(
- $shopAdapterMock,
- $shopTemplateCacheServiceMock,
- $containerCacheMock,
- $moduleCacheServiceMock,
- $contextMock
- );
+ return $contextMock;
+ }
- $command->run(
- $this->createMock(InputInterface::class),
- $this->createMock(OutputInterface::class),
- );
+ private function getShopCacheCleanerMock(): ShopCacheCleanerInterface
+ {
+ $shopCacheCleanerMock = $this->createMock(ShopCacheCleanerInterface ::class);
+ $shopCacheCleanerMock->expects($this->once())->method('clearAll');
+
+ return $shopCacheCleanerMock;
}
}
diff --git a/tests/Unit/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriberTest.php b/tests/Unit/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriberTest.php
index 98ca100eaa3..b6a353d3c9f 100644
--- a/tests/Unit/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriberTest.php
+++ b/tests/Unit/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriberTest.php
@@ -9,29 +9,24 @@
namespace OxidEsales\EshopCommunity\Tests\Unit\Internal\Framework\Module\Cache;
+use OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\InvalidateModuleCacheEventSubscriber;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Event\FinalizingModuleActivationEvent;
-use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Event\FinalizingModuleDeactivationEvent;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Event\ModuleSetupEvent;
use PHPUnit\Framework\TestCase;
-/**
- * @internal
- */
-class InvalidateModuleCacheEventSubscriberTest extends TestCase
+final class InvalidateModuleCacheEventSubscriberTest extends TestCase
{
- public function testSubscriberCallsModuleCacheService()
+ public function testSubscriberCallsModuleCacheService(): void
{
- $moduleCacheService = $this->getMockBuilder(ModuleCacheServiceInterface::class)->getMock();
- $moduleCacheService
+ $shopCacheCleaner = $this->getMockBuilder(ShopCacheCleanerInterface::class)->getMock();
+ $shopCacheCleaner
->expects($this->once())
- ->method('invalidate');
+ ->method('clear');
$event = new class (1, 'testModuleId') extends ModuleSetupEvent {
};
- $subscriber = new InvalidateModuleCacheEventSubscriber($moduleCacheService);
+ $subscriber = new InvalidateModuleCacheEventSubscriber($shopCacheCleaner);
$subscriber->invalidateModuleCache($event);
}
}