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

[PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist #28966

Merged
merged 1 commit into from Nov 15, 2018

Conversation

Projects
None yet
4 participants
@karser
Contributor

karser commented Oct 24, 2018

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #28961
License MIT

Please take a look at the tests I added - they describe the issue. It has to do with the priorities: findAdderAndRemover('User', 'email') is called earlier than $this->isMethodAccessible('User', 'setEmail', 1)

@nicolas-grekas nicolas-grekas changed the title from [PropertyAccessor][php5] Fix unable to write to singular property using setter while plural adder/remover exist to [PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist Oct 24, 2018

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Oct 24, 2018

@karser

This comment has been minimized.

Contributor

karser commented Oct 31, 2018

@nicolas-grekas This bug exists in 4.1 and master, is this PR going to be merged in there as well?

@nicolas-grekas

This comment has been minimized.

Member

nicolas-grekas commented Nov 6, 2018

@karser yes: we regularly merge lower branches into upper ones.

@nicolas-grekas

This comment has been minimized.

Member

nicolas-grekas commented Nov 15, 2018

Thank you @karser.

@nicolas-grekas nicolas-grekas merged commit 8238f16 into symfony:3.4 Nov 15, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

nicolas-grekas added a commit that referenced this pull request Nov 15, 2018

bug #28966 [PropertyAccessor] Fix unable to write to singular propert…
…y using setter while plural adder/remover exist (karser)

This PR was merged into the 3.4 branch.

Discussion
----------

[PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28961
| License       | MIT

Please take a look at the tests I added - they describe the issue. It has to do with the priorities: `findAdderAndRemover('User', 'email')` is called earlier than `$this->isMethodAccessible('User', 'setEmail', 1)`

Commits
-------

8238f16 [PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist

@fabpot fabpot referenced this pull request Nov 16, 2018

Merged

Release v4.2.0-BETA2 #29237

This was referenced Nov 26, 2018

@bendavies

This comment has been minimized.

Contributor

bendavies commented Nov 26, 2018

I think we have a problem here which has caused a regression, or at least a change in behaviour.

If you have a collection property which has a setter, an adder and a remover:

class Foo
{
    private $invoices = [];

    public function setInvoices(array $invoices): void
    {
        //...
    }

    public function addInvoice(Invoice $invoice): void
    {
        //...
    }

    public function removeInvoice(Invoice $item): void
    {
        //...
    }
}

prior to this change, the adder/remover were used over the setter, but with this change, the setter is prioritized over the adder/remover.

Yes, setInvoices should behave identically to removeInvoice(),addInvoice(), but the change in behaviour is there regardless.

Is this an intended, acceptable consequence?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment