Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom cache clearer #785

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MBO_CDC_URL="https://assets.prestashop3.com/dst/mbo/v1/mbo-cdc.umd.js"
DISTRIBUTION_API_URL="https://mbo-api.prestashop.com"
SENTRY_CREDENTIALS=""
SENTRY_ENVIRONMENT=""
SENTRY_CREDENTIALS="https://[email protected]/6520457"
SENTRY_ENVIRONMENT="production"
ADDONS_API_URL="https://api-addons.prestashop.com"

# For testing purpose only
Expand Down
8 changes: 0 additions & 8 deletions config/services/overrides.yml

This file was deleted.

22 changes: 0 additions & 22 deletions src/Addons/Subscriber/ModuleManagementEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use PrestaShop\Module\Mbo\Module\Repository;
use PrestaShop\Module\Mbo\Service\View\ContextBuilder;
use PrestaShop\Module\Mbo\Tab\TabCollectionProviderInterface;
use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface;
use PrestaShop\PrestaShop\Core\Module\ModuleInterface;
use PrestaShopBundle\Event\ModuleManagementEvent;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -72,14 +71,6 @@ class ModuleManagementEventSubscriber implements EventSubscriberInterface
*/
private $versionChangeApplyConfigCommandHandler;

/**
* @var CacheClearerInterface
*/
private $cacheClearer;

/** @var bool */
private $cleared = false;

public function __construct(
LoggerInterface $logger,
Repository $moduleRepository,
Expand All @@ -88,7 +79,6 @@ public function __construct(
Client $distributionClient,
AdminAuthenticationProvider $adminAuthenticationProvider,
VersionChangeApplyConfigCommandHandler $versionChangeApplyConfigCommandHandler,
CacheClearerInterface $cacheClearer,
) {
$this->logger = $logger;
$this->moduleRepository = $moduleRepository;
Expand All @@ -97,7 +87,6 @@ public function __construct(
$this->distributionClient = $distributionClient;
$this->adminAuthenticationProvider = $adminAuthenticationProvider;
$this->versionChangeApplyConfigCommandHandler = $versionChangeApplyConfigCommandHandler;
$this->cacheClearer = $cacheClearer;
}

public static function getSubscribedEvents(): array
Expand All @@ -116,12 +105,10 @@ public static function getSubscribedEvents(): array
['onUninstall'],
],
ModuleManagementEvent::ENABLE => [
['clearSfCache'],
['clearCatalogCache'],
['onEnable'],
],
ModuleManagementEvent::DISABLE => [
['clearSfCache'],
['clearCatalogCache'],
['onDisable'],
],
Expand All @@ -130,7 +117,6 @@ public static function getSubscribedEvents(): array
['onUpgrade'],
],
ModuleManagementEvent::RESET => [
['clearSfCache'],
['clearCatalogCache'],
['onReset'],
],
Expand All @@ -144,14 +130,6 @@ public function clearCatalogCache(): void
$this->contextBuilder->clearCache();
}

public function clearSfCache(ModuleManagementEvent $event): void
{
if (!$this->cleared) {
$this->cacheClearer->clear();
$this->cleared = true;
}
}

public function onInstall(ModuleManagementEvent $event): void
{
$this->logEvent(ModuleManagementEvent::INSTALL, $event);
Expand Down
5 changes: 3 additions & 2 deletions src/Api/Service/ModuleTransitionExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use PrestaShop\Module\Mbo\Module\Exception\UnknownModuleTransitionCommandException;
use PrestaShop\Module\Mbo\Module\Module;
use PrestaShop\Module\Mbo\Module\ValueObject\ModuleTransitionCommand;
use PrestaShop\PrestaShop\Adapter\Cache\Clearer\SymfonyCacheClearer;
use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface;
use Symfony\Component\HttpFoundation\Session\Session;

Expand Down Expand Up @@ -114,8 +115,8 @@ public function execute(...$parameters): array
if (ModuleTransitionCommand::MODULE_COMMAND_DOWNLOAD === $transition) {
// Clear the cache after download to force reload module services
try {
/** @var CacheClearerInterface $cacheClearer */
$cacheClearer = $psMbo->get('mbo.symfony_cache_clearer');
/** @var CacheClearerInterface|false $cacheClearer */
$cacheClearer = $psMbo->get(SymfonyCacheClearer::class);
} catch (\Exception $e) {
ErrorHelper::reportError($e);
$cacheClearer = false;
Expand Down
85 changes: 0 additions & 85 deletions src/Service/MboSymfonyCacheClearer.php

This file was deleted.

11 changes: 7 additions & 4 deletions src/Traits/HaveConfigurationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
namespace PrestaShop\Module\Mbo\Traits;

use Configuration;
use PrestaShop\Module\Mbo\Service\MboSymfonyCacheClearer;
use PrestaShop\PrestaShop\Adapter\Cache\Clearer\SymfonyCacheClearer;
use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface;
use Symfony\Component\Dotenv\Dotenv;

trait HaveConfigurationPage
Expand Down Expand Up @@ -147,9 +148,11 @@ private function saveNewDotenvData(string $envFilePath): string
$dotEnv = new Dotenv();
$dotEnv->overload($envFilePath);

/** @var MboSymfonyCacheClearer $cacheClearer */
$cacheClearer = $this->get(MboSymfonyCacheClearer::class);
$cacheClearer->clear();
/** @var CacheClearerInterface|null $cacheClearer */
$cacheClearer = $this->get(SymfonyCacheClearer::class);
if ($cacheClearer) {
$cacheClearer->clear();
}

$message = '<div style="padding-bottom: 15px;">Configuration updated to :
<ul><li>MBO : ' . ucfirst($newMboValue) . '</li>
Expand Down
3 changes: 2 additions & 1 deletion src/Traits/Hooks/UseActionBeforeUpgradeModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use PrestaShop\Module\Mbo\Helpers\ErrorHelper;
use PrestaShop\Module\Mbo\Module\ActionsManager;
use PrestaShop\Module\Mbo\Service\HookExceptionHolder;
use PrestaShop\PrestaShop\Adapter\Cache\Clearer\SymfonyCacheClearer;
use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface;
use PrestaShop\PrestaShop\Core\File\Exception\FileNotFoundException;
use PrestaShop\PrestaShop\Core\Module\SourceHandler\SourceHandlerNotFoundException;
Expand Down Expand Up @@ -104,7 +105,7 @@ private function purgeCache(): void
{
try {
/** @var CacheClearerInterface|null $cacheClearer */
$cacheClearer = $this->get(CacheClearerInterface::class);
$cacheClearer = $this->get(SymfonyCacheClearer::class);
if (null === $cacheClearer) {
throw new ExpectedServiceNotFoundException('Unable to get MboCacheClearer service');
}
Expand Down