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

[Validator] Add warning about closure not being cachable#15172

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

Merged
javiereguiluz merged 1 commit intosymfony:4.4fromNyholm:validator-callback-cache
Mar 31, 2021

Conversation

@Nyholm
Copy link
Member

Follow up fromsymfony/symfony#40645

The annotation cache will not work withClosure.

If I understand correctly, it is not possible to have external dependencies in your custom validator AND get your annotation cached. You have to chose one or the other.

Seldaek reacted with thumbs up emoji
@Nyholm
Copy link
MemberAuthor

The alternative is to use Yaml, XML or PHP.

@javiereguiluzjaviereguiluz merged commitc09eacc intosymfony:4.4Mar 31, 2021
@javiereguiluz
Copy link
Member

A good addition! Thanks Tobias.

nicolas-grekas added a commit to symfony/symfony that referenced this pull requestApr 1, 2021
This PR was squashed before being merged into the 4.4 branch.Discussion----------[FrameworkBundle] Dont store cache misses on warmup| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#38694| License       | MIT| Doc PR        |symfony/symfony-docs#15172When we are warming the annotation cache, we are reading all annotation into an `ArrayAdapter`. When we are done we move the values to a `PhpArrayAdapter` to store them in a file.@Seldaek [found out](#38694 (comment)) that when you are using a custom constraint with a `Symfony\Component\Validator\Constraints\Callback`, there is a strange error like:> Can use "yield from" only with arrays and TraversablesThat is because the `Closure` in the `Symfony\Component\Validator\Constraints\Callback` cannot be serialised and saved to cache. But since the `ArrayAdapter` is also [storing misses as null](#35362), the null values are understood as real values.When all values are moved to the `PhpArrayAdapter` and we ask the cache for a value (via Doctrine's `CacheProvider`), it will return `null` as a value instead of `false` as a cache miss. And `null` is not something one could "yield from".Commits-------27a22b3 [FrameworkBundle] Dont store cache misses on warmup
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull requestApr 1, 2021
This PR was squashed before being merged into the 4.4 branch.Discussion----------[FrameworkBundle] Dont store cache misses on warmup| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       | Fix #38694| License       | MIT| Doc PR        |symfony/symfony-docs#15172When we are warming the annotation cache, we are reading all annotation into an `ArrayAdapter`. When we are done we move the values to a `PhpArrayAdapter` to store them in a file.@Seldaek [found out](symfony/symfony#38694 (comment)) that when you are using a custom constraint with a `Symfony\Component\Validator\Constraints\Callback`, there is a strange error like:> Can use "yield from" only with arrays and TraversablesThat is because the `Closure` in the `Symfony\Component\Validator\Constraints\Callback` cannot be serialised and saved to cache. But since the `ArrayAdapter` is also [storing misses as null](symfony/symfony#35362), the null values are understood as real values.When all values are moved to the `PhpArrayAdapter` and we ask the cache for a value (via Doctrine's `CacheProvider`), it will return `null` as a value instead of `false` as a cache miss. And `null` is not something one could "yield from".Commits-------27a22b34af [FrameworkBundle] Dont store cache misses on warmup
@NyholmNyholm deleted the validator-callback-cache branchApril 6, 2021 09:47
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

3 participants

@Nyholm@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp