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

[PropertyAccess] Do not silence TypeErrors from client code.#23100

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
fabpot merged 1 commit intosymfony:3.2fromtsufeki:fix-property-accessor-silencing-errors
Jun 14, 2017
Merged

[PropertyAccess] Do not silence TypeErrors from client code.#23100

fabpot merged 1 commit intosymfony:3.2fromtsufeki:fix-property-accessor-silencing-errors
Jun 14, 2017

Conversation

@tsufeki
Copy link
Contributor

QA
Branch?3.2
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PR

Fixes TypeError silencing insetValue() when said error is thrown inside setter/adder/etc.

An example is given in the included test, but more real-life story is botched accessors for a many-to-one association on a Doctrine entity:

class B {functionsetA(A$a) {... }// forgotten "= null" here}class A {functionremoveB(B$b) {if ($this->bs->contains($b)) {$this->bs->removeElement($b);$b->setA(null);// TypeError thrown    }return$this;  }}

No error is shown to the user, even though removing doesn't work.

This bug is not present in 2.7 & 2.8.

self::throwInvalidArgumentException($e->getMessage(),$e->getTrace(),0);

// It wasn't thrown in this class so rethrow it
throw$e;
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't be this done inthrowInvalidArgumentException instead?

Copy link
Member

Choose a reason for hiding this comment

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

no, because it is used elsewhere too

Copy link
Member

@nicolas-grekasnicolas-grekasJun 9, 2017
edited
Loading

Choose a reason for hiding this comment

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

shouldn't the other place also throw?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

the other place is error handler callback for PHP 5, there is no exception to rethrow, and errors are passed correctly to the original handler (here)

@nicolas-grekasnicolas-grekas added this to the3.2 milestoneJun 9, 2017
@fabpot
Copy link
Member

Thank you@tsufeki.

@fabpotfabpot merged commit45b961d intosymfony:3.2Jun 14, 2017
fabpot added a commit that referenced this pull requestJun 14, 2017
…e. (tsufeki)This PR was merged into the 3.2 branch.Discussion----------[PropertyAccess] Do not silence TypeErrors from client code.| Q             | A| ------------- | ---| Branch?       | 3.2| Bug fix?      | yes| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Fixes TypeError silencing in `setValue()` when said error is thrown inside setter/adder/etc.An example is given in the included test, but more real-life story is botched accessors for a many-to-one association on a Doctrine entity:```phpclass B {  function setA(A $a) { ... } // forgotten "= null" here}class A {  function removeB(B $b) {    if ($this->bs->contains($b)) {      $this->bs->removeElement($b);      $b->setA(null); // TypeError thrown    }    return $this;  }}```No error is shown to the user, even though removing doesn't work.This bug is not present in 2.7 & 2.8.Commits-------45b961d [PropertyAccess] Do not silence TypeErrors from client code.
@tsufeki
Copy link
ContributorAuthor

@fabpot I think@requires PHP 7.0 on the test got lost in the merge.

@fabpot
Copy link
Member

@tsufeki Indeed, not sure how it happened. Anyway, fixed in8dc00bb. Thanks.

This was referencedJul 4, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@dunglasdunglasdunglas approved these changes

+1 more reviewer

@theofidrytheofidrytheofidry left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.2

Development

Successfully merging this pull request may close these issues.

7 participants

@tsufeki@fabpot@dunglas@nicolas-grekas@stof@theofidry@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp