Skip to content
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

[DDC-3444] Refresh cascading of lazy loaded associations does not work #1218

Open
wants to merge 3 commits into
base: old-prototype-3.x
Choose a base branch
from

Conversation

martijndwars
Copy link

As described in DDC-1987, cascading of a refresh to lazy loaded associations does not work. I designed a test case to illustrate this problem.

The test case uses Gearman to simulate concurrent requests in a single test. This makes things a bit harder to understand, but I had no idea how to simulate concurrency without it. Please let me know how I can improve the test case.

@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-3444

We use Jira to track the state of pull requests and the versions they got
included in.

@adicosoi
Copy link

Hello,

I know this is somehow off-topic but I can really use some help.

There is an issue with refresh on OneToMany relations with orphanRemoval=true.

When removeElement is called on the collection the elements is correctly added on the UnitOfWork orphanRemovals. When the main entity is refreshed, the collection is also correctly refreshed, due to cascade refresh, but if the flush is called the element of the collection is removed anyway, because although the collection is correctly refreshed, the UnitOfWork orphanRemovals is not unset for this entity.

Any suggestions or workarounds for this issue.

Thank you

@Ocramius
Copy link
Member

All tests pass when this patch is applied to master, therefore either the test is not exposing the issue correctly or it was fixed.

@martijndwars please check it again if you can.

@Ocramius Ocramius changed the title Failing test case for cascading refresh [DDC-3444] [Test] Failing test case for cascading refresh Jan 17, 2015
@martijndwars
Copy link
Author

I believe the bug still exists @Ocramius. I tried to provide a clearer test case. It still uses two models: Order which has a one-to-many association with Item. When I refresh Order, I expect that its associated Items are refreshed as well. However, only a refresh for Order is triggered.

The test case is cluttered with a lot of boilerplate and I had to change some fields from private to protected to be able test these things. Not sure I was allowed to do so, but I did not know how to test it differently.

@stof
Copy link
Member

stof commented Jan 17, 2015

Please don't change the visibility just for testing purpose. This is very bad. Changing the visibility to protected impacts the maintenance of the library (we have to provide BC on protected things, or at least try to provide it)

@stof
Copy link
Member

stof commented Jan 17, 2015

You should write a test reproducing the actual issue you had (which does not involve accessing internal properties) to ensure things work.

@beberlei
Copy link
Member

-1 on the private => protected

@fprochazka
Copy link
Contributor

@beberlei 👍 agreed

@martijndwars
Copy link
Author

Thanks for the suggestions, I reverted my last commit. My original test case reproduces the issue I had. However, because it involves concurrency it is a bit hard (and slow) to run the tests. I currently run the following commands in this order (note the two worker instances):

  1. vendor/bin/phpunit tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1987TestWorker.php
  2. vendor/bin/phpunit tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1987TestWorker.php
  3. vendor/bin/phpunit tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1987Test.php

When manually running the above commands the unit test fails. TravisCI will probably skip the test, because it won't have the Gearman workers running.

@Ocramius Ocramius changed the title [DDC-3444] [Test] Failing test case for cascading refresh [DDC-3444] [Test] Refresh cascading of lazy loaded associations does not work Jan 24, 2015
@Ocramius Ocramius changed the title [DDC-3444] [Test] Refresh cascading of lazy loaded associations does not work [DDC-3444] Refresh cascading of lazy loaded associations does not work Jan 24, 2015
@yellow1912
Copy link

It seems like this issue is still in the latest version of Doctrine?

@Ocramius
Copy link
Member

@yellow1912 since it's not closed: yes, very likely.

@zluiten
Copy link
Contributor

zluiten commented Oct 27, 2017

Provided a fix for this in #6798

Base automatically changed from master to old-prototype-3.x February 23, 2021 08:18
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.

9 participants