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

IBX-6494: Fixed copying of non-translatable fields to later versions #394

Merged
merged 3 commits into from
May 7, 2024

Conversation

barw4
Copy link
Member

@barw4 barw4 commented Nov 14, 2023

Question Answer
JIRA issue IBX-6494
Type bug
Target Ibexa version v3.3
BC breaks no

The issue was present before the copyNonTranslatableFieldsFromPublishedVersion was introduced. However, this method would allow us to handle also the case given in the public ticket.

Maintainer update

QA

This fix makes non-translatable fields to be copied regardless of if they're coming from higher or lower version number, so we need some extensive testing both for scenario in the ticket and some other ideas of how Editor could manipulate content and possibly break it. The version number simple math comparison (>) was there probably since eZ Publish. However I think this was never a good determinant of if something should be overridden.

Side note: would be nice to have in such case a version comparison response which would result in an UI dialog stating that the field changed in some other version, prompting user to choose proper value. But we're nowhere near that yet.

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (master for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ezsystems/engineering-team).

@barw4 barw4 added Bug Something isn't working Ready for review labels Nov 14, 2023
@barw4 barw4 self-assigned this Nov 14, 2023
Copy link

sonarcloud bot commented Nov 14, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@barw4 barw4 marked this pull request as ready for review November 15, 2023 09:14
@barw4 barw4 requested a review from a team November 15, 2023 09:14
@@ -1517,10 +1517,7 @@ protected function copyNonTranslatableFieldsFromPublishedVersion(APIContent $cur
$publishedContent = $this->internalLoadContentById($versionInfo->getContentInfo()->getId());
$publishedVersionInfo = $publishedContent->getVersionInfo();

if (
!$publishedVersionInfo->isPublished()
Copy link
Contributor

Choose a reason for hiding this comment

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

Isnt that going to break some cases when things are not copied for translations (\Ibexa\Core\Repository\ContentService::copyTranslationsFromPublishedVersion) and then some other fields will be copied here?

Or isnt it going to break publishing older version, with overriding all fields with current ones?

Copy link
Member Author

@barw4 barw4 Nov 30, 2023

Choose a reason for hiding this comment

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

@ViniTou

Isnt that going to break some cases when things are not copied for translations (\Ibexa\Core\Repository\ContentService::copyTranslationsFromPublishedVersion) and then some other fields will be copied here?

Hmm, I cannot see why removing this condition would break that. The updated method only deals with nontranslatable fields and those are not handled in copyTranslationsFromPublishedVersion.

Or isnt it going to break publishing older version, with overriding all fields with current ones?

I've just tested this and it seems that version 2 (3 is published) properly overridden version 3 so values from version 3 weren't copied into earlier version 2 during publishing if that's what you had in mind.

Copy link
Contributor

Choose a reason for hiding this comment

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

The updated method only deals with nontranslatable fields and those are not handled in copyTranslationsFromPublishedVersion.

Yes, my point was, that right now some fields could be copied/not copied there, and be copied/not copied here as the logic now differs.

But I guess, maybe QA will stumble on specific case as I cant come up with proper testing scenario for it.

@barw4 barw4 requested review from ViniTou and a team November 30, 2023 15:28
@@ -1517,10 +1517,7 @@ protected function copyNonTranslatableFieldsFromPublishedVersion(APIContent $cur
$publishedContent = $this->internalLoadContentById($versionInfo->getContentInfo()->getId());
$publishedVersionInfo = $publishedContent->getVersionInfo();

if (
!$publishedVersionInfo->isPublished()
Copy link
Contributor

Choose a reason for hiding this comment

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

The updated method only deals with nontranslatable fields and those are not handled in copyTranslationsFromPublishedVersion.

Yes, my point was, that right now some fields could be copied/not copied there, and be copied/not copied here as the logic now differs.

But I guess, maybe QA will stumble on specific case as I cant come up with proper testing scenario for it.

@barw4 barw4 requested a review from a team December 8, 2023 09:36
Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

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

@barw4 could you rebase this PR so we can see the current state of CI.

eZ/Publish/Core/Repository/ContentService.php Show resolved Hide resolved
@alongosz alongosz changed the title IBX-6494: Copy nontranslatable fields to later versions IBX-6494: Fixed copying of non-translatable fields to later versions Mar 26, 2024
@barw4 barw4 force-pushed the ibx-6494-copy-nontranslatable-to-later-versions branch from d785b44 to 38d2838 Compare March 26, 2024 13:36
@barw4
Copy link
Member Author

barw4 commented Mar 26, 2024

@barw4 could you rebase this PR so we can see the current state of CI.

Done, will send to QA after it's green

@alongosz alongosz requested a review from a team March 26, 2024 13:40
@tomaszszopinski
Copy link

tomaszszopinski commented Apr 9, 2024

Note from QA: Ive observed a behaviour that might be a bug;
Steps to reproduce:

  1. Create foo content item (from JIRA)
  2. Add translation to this content item (.ie ger-DE)
  3. Edit eng-GB translation (change image)
  4. Publish
  5. Image in ger-DE translation is not changing (it changes only after editing & publishing)

Without this PR this behaviour is not happening.

kernel-394.mov

@barw4
Copy link
Member Author

barw4 commented Apr 15, 2024

@alongosz @ViniTou @konradoboza @Nattfarinn calling for a second review.

As @tomaszszopinski noticed the first iteration of this PR fixed the issue from the ticket but broke the original idea for this method (older versions with different languages were not updated properly with non-translatable fields). It's really hard to explain but the newest change will allow changing a value of a non-translatable field with an older published field's value only if a current version is older than a published one. Test was added that validates this update.

Copy link

sonarcloud bot commented Apr 15, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@alongosz alongosz requested a review from a team May 6, 2024 09:28
Copy link

@tomaszszopinski tomaszszopinski left a comment

Choose a reason for hiding this comment

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

QA approved on IbexaDXP 3.3 commerce.

@alongosz alongosz merged commit b5fe9ad into 1.3 May 7, 2024
23 checks passed
@alongosz alongosz deleted the ibx-6494-copy-nontranslatable-to-later-versions branch May 7, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working QA approved
Development

Successfully merging this pull request may close these issues.

9 participants