Skip to content

Commit

Permalink
Make the always_expire_wfd_meta_resources config setting work regar…
Browse files Browse the repository at this point in the history
…dless of `kernel.debug` mode
  • Loading branch information
mpdude committed Aug 30, 2024
1 parent cf26d07 commit 779a4dd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 25 deletions.
19 changes: 0 additions & 19 deletions src/Config/CacheBustingResourceChecker.php

This file was deleted.

9 changes: 8 additions & 1 deletion src/Config/WfdMetaConfigCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ class WfdMetaConfigCache implements ConfigCacheInterface
/** @var ConfigCacheInterface */
private $innerCache;

public function __construct($file, ConfigCacheInterface $innerCache, MetaQueryFactory $metaQueryFactory)
private bool $alwaysExpireWfdMetaResources;

public function __construct($file, ConfigCacheInterface $innerCache, MetaQueryFactory $metaQueryFactory, bool $alwaysExpire = false)
{
$this->file = $file;
$this->innerCache = $innerCache;
$this->metaQueryFactory = $metaQueryFactory;
$this->alwaysExpireWfdMetaResources = $alwaysExpire;
}

public function getPath(): string
Expand Down Expand Up @@ -62,6 +65,10 @@ public function isWfdMetaFresh(): bool
return true;
}

if ($this->alwaysExpireWfdMetaResources) {
return false;
}

$metaQuery = $this->metaQueryFactory->create();

foreach ($wfdMetaResources['resources'] as $wfdMetaResource) {
Expand Down
7 changes: 5 additions & 2 deletions src/Config/WfdMetaConfigCacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ class WfdMetaConfigCacheFactory implements ConfigCacheFactoryInterface
*/
private $lockFactory;

public function __construct(ConfigCacheFactoryInterface $configCacheFactory, MetaQueryFactory $metaQueryFactory, LockFactory $lockFactory)
private bool $alwaysExpireWfdMetaResources;

public function __construct(ConfigCacheFactoryInterface $configCacheFactory, MetaQueryFactory $metaQueryFactory, LockFactory $lockFactory, bool $alwaysExpireWfdMetaResources = false)
{
$this->configCacheFactory = $configCacheFactory;
$this->metaQueryFactory = $metaQueryFactory;
$this->lockFactory = $lockFactory;
$this->alwaysExpireWfdMetaResources = $alwaysExpireWfdMetaResources;
}

public function cache($file, $callback): ConfigCacheInterface
Expand Down Expand Up @@ -70,7 +73,7 @@ public function cache($file, $callback): ConfigCacheInterface

private function createCache($file, ConfigCacheInterface $innerCache): ConfigCacheInterface
{
return new WfdMetaConfigCache($file, $innerCache, $this->metaQueryFactory);
return new WfdMetaConfigCache($file, $innerCache, $this->metaQueryFactory, $this->alwaysExpireWfdMetaResources);
}

private function fillCache($callback, ConfigCacheInterface $cache): void
Expand Down
4 changes: 1 addition & 3 deletions src/DependencyInjection/WebfactoryWfdMetaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

if ($config['always_expire_wfd_meta_resources']) {
$yamlLoader->load('cache_busting.yml');
}
$container->setParameter('webfactory_wfd_meta.always_expire_wfd_meta_resources', $config['always_expire_wfd_meta_resources']);
}
}
1 change: 1 addition & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<tag name="monolog.logger" channel="webfactory_wfd_meta" />
</service>
</argument>
<argument>%webfactory_wfd_meta.always_expire_wfd_meta_resources</argument>
</service>
</services>
</container>

0 comments on commit 779a4dd

Please sign in to comment.