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

Fix EZP-25366: relation fields aren't copied correctly #1558

Merged
merged 4 commits into from
Jan 28, 2016

Conversation

bdunogier
Copy link
Member

Fixes http://jira.ez.no/browse/EZP-25366

When copying content with relation fields, relations on the copy were not properly registered. This is fixed by applying the same logic used in createContent() and updateContent(): relations inside fields are recorded during copy, and registered using the persistence later at the end.

TODO

  • Handle other versions
  • Check if something must be done about existing relations
  • Tests
  • Add integration test for Content Copy
  • Add integration test for Subtree Copy

@bdunogier
Copy link
Member Author

Ping @joaoinacio & @andrerom

@@ -1586,6 +1586,9 @@ public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $dest
);
}

$relations = $locationIdToContentIdMapping = array();
Copy link
Contributor

Choose a reason for hiding this comment

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

short notation? :)

@bdunogier bdunogier force-pushed the ezp25366-copy_content_relation_field branch 3 times, most recently from 48519a5 to 7d53274 Compare January 15, 2016 18:45
@andrerom
Copy link
Contributor

Looks good, as for LocationService->copySubtree() seen any ways yet on how we can tackle it there?

@bdunogier
Copy link
Member Author

Looks good, as for LocationService->copySubtree() seen any ways yet on how we can tackle it there?

$relationProcessor->updateContentRelations() needs to be called after $contentHandler->copy().

Unfortunately, subtreeCopy is made at persistence level, meaning that we do not have the list of copied content. we could of course get it, but it would be quite heavy, and I would not do that lightly...

@joaoinacio
Copy link

May be wrong here as I didn't dig deep into the tests, but it seems this could have the same problem as a recent issue, whereby relations from old versions are taken into account (kept in object_link) when they shouldn't.

Example:

  v1 | eng-GB | -> rel A
  v2 | fre-FR | -> rel B
- v3 | eng-GB | -> rel C

Correct content relations would be B , C but not A.

@joaoinacio
Copy link

Also, I'm left wondering if this solution be helpful in the context of https://jira.ez.no/browse/EZP-24540 ?

@bdunogier
Copy link
Member Author

May be wrong here as I didn't dig deep into the tests, but it seems this could have the same problem as a recent issue, whereby relations from old versions are taken into account (kept in object_link) when they shouldn't.

This bugfix doesn't really intend to fix this, to be frank.

@andrerom andrerom force-pushed the ezp25366-copy_content_relation_field branch from 7d53274 to 4b97d3a Compare January 27, 2016 14:37
@andrerom andrerom self-assigned this Jan 27, 2016
@andrerom
Copy link
Contributor

Updated approach, review ping @bdunogier @Plopix @crevillo

@Plopix
Copy link
Contributor

Plopix commented Jan 27, 2016

tested with a command like this:

        // subtree
        $repo->getLocationService()->copySubtree($source->location, $dest->location);

        // simple
        $locationStruct = $repo->getLocationService()->newLocationCreateStruct($dest->location->id);
        $repo->getContentService()->copyContent($source->content->contentInfo, $locationStruct);

And also tested in the original context of the explained bug in the issue.

ping @andrerom @bdunogier => Nice job guys ! It works!

@bdunogier
Copy link
Member Author

Great job @andrerom.

+1

@andrerom andrerom force-pushed the ezp25366-copy_content_relation_field branch from a24eee9 to 4f9d268 Compare January 27, 2016 21:53
@andrerom
Copy link
Contributor

Great job @andrerom.

Thanks, but did actually miss adding 1 test in RelationSearchMultivaluedBaseIntegrationTest, which given it was a duplicate of RelationSearchBaseIntegrationTest made me change them into 1 trait during last rebase. So hopefully even better now :)

Side: Failure is because of behat, issues with some other unrelated merges afaik, should be checked before next sub release.

@bdunogier
Copy link
Member Author

RelationSearchMultivaluedBaseIntegrationTest, which given it was a duplicate of RelationSearchBaseIntegrationTest made me change them into 1 trait during last rebase

Yes, this is one part of tests where we have a big debt to pay.

@yannickroger
Copy link
Contributor

+1

@bdunogier
Copy link
Member Author

Shouldn't you squash the integration tests with the bugfix ? We do backport the tests as well, unless I am mistaken.

@andrerom
Copy link
Contributor

I'll do that on the back port, in case further back ports, thanks for reviewing :)

andrerom added a commit that referenced this pull request Jan 28, 2016
…n_field

Fix EZP-25366: relation fields aren't copied correctly
@andrerom andrerom merged commit e82d334 into master Jan 28, 2016
@andrerom andrerom deleted the ezp25366-copy_content_relation_field branch January 28, 2016 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants