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] Ensure a group is set on a constraint (fix BC break)#44847

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
lyrixx wants to merge1 commit intosymfony:4.4fromlyrixx:validator

Conversation

@lyrixx
Copy link
Member

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#44846
LicenseMIT
Doc PR

@carsonbotcarsonbot added this to the4.4 milestoneDec 29, 2021
@lyrixxlyrixx changed the title[Validator] Ensure a group is set on a contraint (fix BC break)[Validator] Ensure a group is set on a constraint (fix BC break)Dec 29, 2021
@nicolas-grekas
Copy link
Member

nicolas-grekas commentedDec 29, 2021
edited
Loading

Are you calling the constructor? Because if not, that's the issue. The property is supposed to be lazily initialized (that's why it's unset in the constructor)

@lyrixx
Copy link
MemberAuthor

Are you calling the constructor?

No I don't. It used to work in previous version of symfony. And nothing force us to call the constructor (like it can be done in Command class). So to me it's a BC break and this PR solves this issue

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedDec 29, 2021
edited
Loading

This change is going to break Composite constraints, see

if (!isset(((array)$this)['groups'])) {
$mergedGroups = [];
foreach ($nestedConstraintsas$constraint) {
foreach ($constraint->groupsas$group) {
$mergedGroups[$group] =true;
}
}
// prevent empty composite constraint to have empty groups
$this->groups =array_keys($mergedGroups) ?: [self::DEFAULT_GROUP];
$this->$compositeOption =$nestedConstraints;
return;
}

I understand this worked before because the property was undeclared. But to adapt to PHP 8.2, we have to declare all properties.
Using a typed property would work, but I'm not sure we can do so since we'll consider that adding the type is a BC break...

Any other idea?

@nicolas-grekas
Copy link
Member

Instead, can't we check that the property is null, meaning it need to be unset and __get again before being usable?

@stof
Copy link
Member

Also, I suggest trigger a deprecation saying that the parent constructor must be called.

@lyrixx
Copy link
MemberAuthor

lyrixx commentedDec 29, 2021
edited
Loading

Also, I suggest trigger a deprecation saying that the parent constructor must be called.

how would you do that? with a check in all public method?

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedDec 30, 2021
edited
Loading

What about#44854 instead?
Given that this happens at compilation, I think a LogicException is fine IMHO.

ogizanagi added a commit that referenced this pull requestDec 31, 2021
…en called (nicolas-grekas)This PR was merged into the 4.4 branch.Discussion----------[Validator] throw when Constraint::_construct() has not been called| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#44846| License       | MIT| Doc PR        | -Instead of#44847Commits-------20aacce [Validator] throw when Constraint::_construct() has not been called
@ogizanagi
Copy link
Contributor

Superseded by#44854

@lyrixxlyrixx deleted the validator branchJune 30, 2023 10:23
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasAwaiting requested review from nicolas-grekas

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

5 participants

@lyrixx@nicolas-grekas@stof@ogizanagi@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp