Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix PrePersist EventListener when using merge instead of persist#5570

Closed
moroine wants to merge 2 commits into
doctrine:masterfrom
AdactiveSAS:persistNewEntityViaMerge
Closed

Fix PrePersist EventListener when using merge instead of persist#5570
moroine wants to merge 2 commits into
doctrine:masterfrom
AdactiveSAS:persistNewEntityViaMerge

Conversation

@moroine
Copy link
Copy Markdown

@moroine moroine commented Dec 22, 2015

The merge operation trigger PRE_PERSIST & POST_PERSIST events when we merge a new entity.

The bug that I encounter, is that the PRE_PERSIST event is trigger with the managed copy empty ! I that case my event listener can't access original data.

In order to fix this, I firstly merge entity state into managed copy. I think this is not the best move as it will be copied a second time at line 1888.

I tried to persist after this is done, but it break some unit tests.

@moroine
Copy link
Copy Markdown
Author

moroine commented Feb 2, 2016

@Ocramius I think this is a Bug on merge operation which is critical in my case :/

@moroine
Copy link
Copy Markdown
Author

moroine commented Apr 15, 2016

@DHager, @Ocramius any update on this PR ? I think this is a really bad issue

@moroine
Copy link
Copy Markdown
Author

moroine commented Jun 17, 2016

@Ocramius I wonder about this PR which seems to be ready. What about merging it ?

@Ocramius Ocramius added this to the 2.5.5 milestone Jul 5, 2016
@Ocramius Ocramius self-assigned this Jul 5, 2016
@Ocramius Ocramius removed this from the 2.5.5 milestone Sep 9, 2016
@Ocramius Ocramius removed their assignment Sep 9, 2016
@moroine
Copy link
Copy Markdown
Author

moroine commented Sep 13, 2016

@Ocramius great thing that 2.5.5 especially with fixed spl_hash_object conflict on merge !

I would like to know what about this PR, this is removed from 2.5.5 but this would be on the next one or just delay as this is not in the top of the TODO ?

Thank You !

@Ocramius
Copy link
Copy Markdown
Member

@moroine I had actually looked at the PR, but then didn't manage to review the details (or specifically, the "cause") in time. Let me put a 2.5.6 on it.

@Ocramius Ocramius added this to the 2.5.6 milestone Sep 13, 2016
@Ocramius Ocramius self-assigned this Sep 13, 2016
@moroine moroine closed this Dec 15, 2016
@moroine moroine deleted the persistNewEntityViaMerge branch December 15, 2016 10:39
@moroine moroine restored the persistNewEntityViaMerge branch December 15, 2016 10:39
moroine pushed a commit to AdactiveSAS/doctrine2 that referenced this pull request Dec 15, 2016
…ener when using merge instead of persist)
@moroine
Copy link
Copy Markdown
Author

moroine commented Dec 15, 2016

@Ocramius I made a mistake on my fork repository that closed this PR :'(

I've created a new one #6174 that treat about a similar bug but also fix that one !

Could you check this other PR and may be schedule for the v2.5.6 also ?

Thank You a lot

@moroine moroine reopened this Dec 15, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
…es are merged, but are already in the UoW
Ocramius added a commit that referenced this pull request Dec 18, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
…ener`, since `UnitOfWorkTest` now completely encapsulates the scenarios being covered
Ocramius added a commit that referenced this pull request Dec 18, 2016
Ocramius added a commit that referenced this pull request Dec 18, 2016
…tities-should-also-trigger-prepersist-lifecycle-callbacks-2.5

Backport #6177 - fix #6174 #5570: merging new entities should also trigger prepersist lifecycle callbacks with the merged data
Ocramius added a commit that referenced this pull request Dec 18, 2016
…tities-should-also-trigger-prepersist-lifecycle-callbacks

Fix #6174 #5570: merging new entities should also trigger prepersist lifecycle callbacks with merged entity data
@Ocramius
Copy link
Copy Markdown
Member

Moved to #6177, applied fixes locally, rewrote the tests to reduce cross-test dependencies. 👍

AlexKryvets added a commit to AlexKryvets/doctrine2 that referenced this pull request Dec 23, 2016
This release relaxes [`doctrine/common`](https://github.com/doctrine/common) requirements
in order to allow installation of versions that support PHP 7.1 features in proxy class
generation. Please note that a similar requirement relaxation still needs to be applied to
[`doctrine/dbal`](https://github.com/doctrine/dbal) in order to allow installation of
the latest `doctrine/common` versions. [doctrine#6156](doctrine#6156)

This version also backports some fixes around the eviction of the second level cache entries
of inverse side associations in one-to-many - many-to-one mappings. [doctrine#6159](doctrine#6159)

Further fixes were applied in order to have child classes in inheritance mapping share the
same timestamp region when the second level cache is enabled. [doctrine#6028](doctrine#6028)

Also, `Doctrine\ORM\EntityManager#merge()` now triggers `Doctrine\ORM\Events::prePersist`
listeners with the merged entity state whenever an internal `Doctrine\ORM\UnitOfWork#persist()`
call is implied. [doctrine#6177](doctrine#6177).

Total issues resolved: **8**

- [5570: Fix PrePersist EventListener when using merge instead of persist](doctrine#5570)
- [6028: Make child entity share the timestamp region with parent class](doctrine#6028)
- [6110: Clear $this->collection even when empty, to reset keys](doctrine#6110)
- [6156: Allow doctrine/common 2.7](doctrine#6156)
- [6159: doctrine#5821 Backport doctrine#1551 - Fixed support for inverse side second level cache](doctrine#6159)
- [6174: Merging a new entity with PrePersist event make changes in callback not be considered](doctrine#6174)
- [6177: Fix doctrine#6174 doctrine#5570: merging new entities should also trigger prepersist lifecycle callbacks with merged entity data](doctrine#6177)
- [6178: Backport doctrine#6177 - fix doctrine#6174 doctrine#5570: merging new entities should also trigger prepersist lifecycle callbacks with the merged data](doctrine#6178)

# gpg: directory `/c/Users/PC/.gnupg' created
# gpg: new configuration file `/c/Users/PC/.gnupg/gpg.conf' created
# gpg: WARNING: options in `/c/Users/PC/.gnupg/gpg.conf' are not yet active during this run
# gpg: keyring `/c/Users/PC/.gnupg/pubring.gpg' created
# gpg: Signature made Tue Dec 20 00:49:05 2016 FLEST using DSA key ID 12EC2DF8
# gpg: Can't check signature: public key not found

# Conflicts:
#	lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php
#	lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
#	tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php
#	tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php
#	tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
…ener when using merge instead of persist)
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
… event subscriber triggering on `UnitOfWork` into the `UnitOfWorkTest`
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
…lled when entities are merged, but are already in the UoW
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
…panyContractListener`, since `UnitOfWorkTest` now completely encapsulates the scenarios being covered
alexgurrola pushed a commit to Sitetheory-Archive/doctrine2 that referenced this pull request Apr 13, 2017
…or PHP 5.4 compat (still supported in ORM 2.5.x)
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.

2 participants