8000 [Validator] Allow Validator without the translator component by sroze · Pull Request #28520 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Allow Validator without the translator component #28520

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

Merged
merged 1 commit into from
Sep 20, 2018

Conversation

sroze
Copy link
Contributor
@sroze sroze commented Sep 19, 2018
Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #28210
License MIT
Doc PR ø

Validator should be available without the Translator service. #28210 introduced a regression, it was not the case anymore:


  You have requested a non-existent service "translator".

This fixes it.


foreach ($builder->getMethodCalls() as list($method, $arguments)) {
if ('setTranslator' === $method) {
$translator = $arguments[0] instanceof Reference ? $container->findDefinition($arguments[0]) : $arguments[0];
if ($arguments[0] instanceof Reference) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be enough to make sure that the reference is tagged with IGNORE_ON_INVALID_REFERENCE (see https://symfony.com/doc/4.0/service_container/optional_dependencies.html#ignoring-missing-dependencies)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just setting the reference as "nullable" wouldn't work, we'd have the same error. Though, your put is interesting: I've made sure it ignores the reference only if it's "nullable".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no. I've just reverted 3e545e4 as it would break the ValidatorBuilderInterface. AFAIK, that's the only way of dealing with it here.

@sroze sroze force-pushed the validator-without-translator branch from 3e545e4 to 9e5ea39 Compare September 20, 2018 06:45
@nicolas-grekas nicolas-grekas added this to the next milestone Sep 20, 2018
@sroze sroze force-pushed the validator-without-translator branch from 9e5ea39 to c0d7091 Compare September 20, 2018 06:52
Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(using on-invalid="null" wouldn't remove the need for doing this change as $translator is used below)

@sroze sroze force-pushed the validator-without-translator branch from 5c56d01 to 2dc92d7 Compare September 20, 2018 07:09
@sroze
Copy link
Contributor Author
sroze commented Sep 20, 2018

FYI, it's a very important bug, it prevents the following to work:

composer create-project symfony/website-skeleton:dev-master xxx

@nicolas-grekas
Copy link
Member

Thank you @sroze.

@nicolas-grekas nicolas-grekas merged commit 2dc92d7 into symfony:master Sep 20, 2018
nicolas-grekas added a commit that referenced this pull request Sep 20, 2018
…nt (sroze)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Validator] Allow Validator without the translator component

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28210
| License       | MIT
| Doc PR        | ø

Validator should be available without the Translator service. #28210 introduced a regression, it was not the case anymore:
```

  You have requested a non-existent service "translator".

```

This fixes it.

Commits
-------

2dc92d7 Allow validator without the translator
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0