Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactor behaviour triggered by a flag into separate classes.#7782

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
mpdude wants to merge1 commit intosymfony:masterfromwebfactory:issue-7230/picks/configcache-behaviour-flag
Closed

Refactor behaviour triggered by a flag into separate classes.#7782

mpdude wants to merge1 commit intosymfony:masterfromwebfactory:issue-7230/picks/configcache-behaviour-flag

Conversation

mpdude
Copy link
Contributor

QA
Bug fix?no
New feature?yes (refactoring)
BC breaks?no
Deprecations?no
Tests pass?we'll see :-)
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

The ConfigCache class has two modes of behavior, toggled by the "debug"flag.

Refactoring that into two different classes may seem pointless or overkill at the moment, but gets more interesting once resource checking/validation gets more intricate. Peek atthis if you're curious :-).

It's a pick off#7230.

NB. With the changes from#7781, you probably don't want to useConfigCache anymore but instead have the factory create the right implementation and use it directly.

@mpdude
Copy link
ContributorAuthor

Just noticed we can probably solve validation with a decorator instead of inheritance.

@mpdude
Copy link
ContributorAuthor

This PR has been superseeded by#15738

@mpdudempdude closed thisSep 24, 2015
@mpdudempdude deleted the issue-7230/picks/configcache-behaviour-flag branchSeptember 24, 2015 19:32
fabpot added a commit that referenced this pull requestSep 25, 2015
…pdude)This PR was squashed before being merged into the 2.8 branch (closes#15738).Discussion----------Implement service-based Resource (cache) validation| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets |#7230,#15692,#7782| License       | MIT| Doc PR        |symfony/symfony-docs#5136### OverviewCurrently, any metadata passed to `ConfigCache` (namely implementations of `ResourceInterface`) is serialized to disk. When the `ConfigCache` is validated, the metadata is unserialized and queried through `ResourceInterface::isFresh()` to determine whether the cache is fresh. That way, `ResourceInterface` implementations cannot interact with services, for example a database connection.This PR introduces the new concept of `ResourceCheckers`. Services implementing `ResourceCheckerInterface` can be tagged as `config_cache.resource_checker` with an optional priority.Clients that wish to use `ConfigCache` can then obtain an instance from the `config_cache_factory` service (which implements `ConfigCacheFactoryInterface`). The factory will take care of injecting resource checkers into the `ConfigCache` instance so that they can be used for cache validation.Checking cache metadata is easy for `ResourceCheckers`:* First, the `ResourceCheckerInterface::supports()` implementation is passed the metadata object in question. If the checker cannot handle the type of resource passed, `supports()` should return `false`.* Otherwise, the `ResourceCheckerInterface::isFresh()` method will be called and given the resource as well as the timestamp at which the cache was initialized. If that method returns `false`, the cache is considered stale. If it returns `true`, the resource is considered unchanged and will *not* be passed to any additional checkers.### BC and migration pathThis PR does not (intend to) break BC but it comes with deprecations. The main reason is that `ResourceInterface` contains an `isFresh()` method that does not make sense in the general case of resources.Thus, `ResourceInterface::isFresh()` is marked as deprecated and should be removed in Symfony 3.0. Resource implementations that can (or wish to) be validated in that simple manner can implement the `SelfCheckingResourceInterface` sub-interface that still contains (and will keep) the `isFresh()` method. The change should be as simple as changing the `extends` list.Apart from that, `ResourceInterface` will be kept as the base interface for resource implementations. It is used in several `@api` interfaces and thus cannot easily be substituted.For the Symfony 2.x series, a `BCResourceInterfaceChecker` will be kept that performs validation through `ResourceInterface::isFresh()` but will trigger a deprecation warning. The remedy is to either implement a custom ResourceChecker with a priority higher than -1000; or to switch to the aforementioned `SelfCheckingResourceInterface` which is used at a priority of -990 (without deprecation warning).The `ConfigCache` and `ConfigCacheFactory` classes can be used as previously but do not feature checker-based cache validation.### Outlook and closing remarks:This PR supersedes#7230,#15692 and works at least in parts towards the goal of#7176.The `ResourceCheckerInterface`, `...ConfigCache` and `...ConfigCacheFactory` no longer need to be aware of the `debug` flag. The different validation rules applied previously are now just a matter of `ResourceChecker` configuration (i. e. "no checkers" in `prod`).It might be possible to remove the `debug` flag from Symfony's `Router` and/or `Translator` classes in the future as well because it was only passed on to the `ConfigCache` there.Commits-------20d3722 Implement service-based Resource (cache) validation
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@mpdude

[8]ページ先頭

©2009-2025 Movatter.jp