-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a config setting to make wfd_meta-based caches expire immediately (…
…#28) This adds a new configuration setting: ```yml # config_test.yml webfactory_wfd_meta: always_expire_wfd_meta_resources: true ``` With this setting, `ConfigCache` instances (Symfony Router, Translator, ... maybe?) that include `WfdMetaResource` instances will expire immediately. This is helpful e. g. in functional tests, where you have database-backed routes, translations or similar: You can change the database values and no longer need to think about the `ConfigCaches` or poke `wfd_meta` to make the changes effective.
- Loading branch information
Showing
7 changed files
with
89 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Webfactory\Bundle\WfdMetaBundle\Config; | ||
|
||
use Symfony\Component\Config\Resource\ResourceInterface; | ||
use Symfony\Component\Config\ResourceCheckerInterface; | ||
|
||
class CacheBustingResourceChecker implements ResourceCheckerInterface | ||
{ | ||
public function supports(ResourceInterface $metadata): bool | ||
{ | ||
return $metadata instanceof WfdMetaResource; | ||
} | ||
|
||
public function isFresh(ResourceInterface $resource, int $timestamp): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Webfactory\Bundle\WfdMetaBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
class Configuration implements ConfigurationInterface | ||
{ | ||
public function getConfigTreeBuilder(): TreeBuilder | ||
{ | ||
$treeBuilder = new TreeBuilder('webfactory_wfd_meta'); | ||
|
||
$treeBuilder->getRootNode() | ||
->children() | ||
->booleanNode('always_expire_wfd_meta_resources') | ||
->defaultFalse() | ||
->info('When set to "true", ConfigCache instances that depend on "\Webfactory\Bundle\WfdMetaBundle\Config\WfdMetaResource" will be refreshed every time; useful during functional tests to reload routes etc.'); | ||
|
||
return $treeBuilder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
|
||
_defaults: | ||
public: false | ||
|
||
Webfactory\Bundle\WfdMetaBundle\Config\CacheBustingResourceChecker: | ||
tags: ['config_cache.resource_checker'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
|
||
<defaults autoconfigure="true" autowire="true" public="false" /> | ||
|
||
<service id="Webfactory\Bundle\WfdMetaBundle\Config\WfdMetaConfigCacheFactory" decorates="config_cache_factory"> | ||
<argument type="service" id="Webfactory\Bundle\WfdMetaBundle\Config\WfdMetaConfigCacheFactory.inner" /> | ||
<argument type="service" id="Webfactory\Bundle\WfdMetaBundle\MetaQueryFactory" /> | ||
<argument type="service"> | ||
<service class="Symfony\Component\Lock\LockFactory"> | ||
<argument type="service"> | ||
<service class="Symfony\Component\Lock\Store\FlockStore" /> | ||
</argument> | ||
<call method="setLogger"> | ||
<argument type="service" id="logger" on-invalid="ignore" /> | ||
</call> | ||
<tag name="monolog.logger" channel="webfactory_wfd_meta" /> | ||
</service> | ||
</argument> | ||
</service> | ||
|
||
<service public="true" id="webfactory_wfd_meta.config_cache_factory" alias="Webfactory\Bundle\WfdMetaBundle\Config\WfdMetaConfigCacheFactory"> | ||
<deprecated>The "%alias_id%" alias is deprecated</deprecated> | ||
</service> | ||
|
||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c7a2e2b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpdude Dieser Commit hat die Kompatibilität zu
symfony/config
in Version 4.4 kaputtgemacht, weil dort die MethodeResourceCheckerInterface::isFresh()
noch keinen Type-Hint auf dem zweiten Argumenttimestamp
hat: https://github.com/symfony/config/blob/ed42f8f9da528d2c6cae36fe1f380b0c1d8f0658/ResourceCheckerInterface.php#L44. Können/wollen/müssen wir das fixen?c7a2e2b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
41d743f hat es ja erstmal repariert, weil es Symfony >=5.1 fordert (5.0 wäre ausreichend). Also mit dem Type-Hint jetzt alles gut für Nutzer, die Symfoy 5.1 oder besser können.
Damit haben wir aber Nutzer mit Symfony < 5.0 mit einer kaputten Version zurückgelassen. Weil Du aber mit dem Hochsetzen der Dependencies auch ein Minor Release gemacht hast, habe ich noch genug Beinfreiheit für einen Fix mit einer Version 3.16.2.