[LIVECOPY-288] Protect Button saves wrong protection names if a locale is a default in a tree but not the master default Created: 31/Aug/21  Updated: 20/Sep/21  Resolved: 17/Sep/21

Status: Closed
Project: Live Copy
Component/s: None
Affects Version/s: None
Fix Version/s: 3.2.6

Type: Bug Priority: Blocker
Reporter: Marvin Kerkhoff Assignee: Quach Hao Thien
Resolution: Done Votes: 0
Labels: VN-Analysis, VN-Maintenance, cm-team-support, maintenance
Remaining Estimate: Not Specified
Time Spent: 6d 1.5h
Original Estimate: Not Specified

Attachments: PNG File image-2021-09-06-19-15-07-187.png     PNG File image-2021-09-07-16-49-23-741.png    
Issue Links:
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Release notes required:
Yes
Documentation update required:
Yes
Date of First Response:
Epic Link: Live Copy maintenance
Sprint: Content Mngmt 12, Content Mngmt 13
Story Points: 5

 Description   

Protect Button saves wrong protection names if a locale is a default in a tree but not the master default.

Steps to reproduce

  1.  Create a master tree with en_US as default, de_CH as second and en_GB as third locale
  2.  Create a slave tree with en_US as masterDefaultLocale and en_GB as fallback for this tree.
  3. Go to the page protect button and protect the en_GB version of a property.

Expected results

Because en_GB is not the master default locale the en_GB should be saved as suffix

Actual results

It will create a <propertyName> in the protectedFields property without language suffix.

Development notes

The issue is in the Button:

https://git.magnolia-cms.com/projects/ADDON/repos/live-copy/browse/src/main/java/info/magnolia/livecopy/app/ui/layout/field/ProtectFieldButton.java

It uses an own implementation of isDefaultLocale at line 102. Instead you should use the isDefaultLocale method from https://git.magnolia-cms.com/projects/ADDON/repos/live-copy/browse/src/main/java/info/magnolia/livecopy/i18n/LiveCopyMultiSiteI18nAuthoringSupport.java 



 Comments   
Comment by Quach Hao Thien [ 01/Sep/21 ]

hi marvink2, could you please provide the resources as master page, slave pages, site definition for each page that would help to understand more the issue you are encountering? 

Comment by Marvin Kerkhoff [ 01/Sep/21 ]

Hi Quach,

sorry i am not able to extract a quick example. But the issue is very simple. You are using a different logical implementation in the set protect fields method as you do by getting the default locale in the push methods. So you should set the default locale implementation to the one at the LiveCopyMultiSiteI18nAuthoringSupport. It was extra developed for this purpose.

You could reproduce the issue by creating the trees as following: 

  1. Create a master tree site config with en_US, de_CH, en_GB as locales.
  2. Add en_US as fallback locale.
  3. Create a slave tree site config with en_US and en_GB.
  4. Add en_US as masterDefaultLocale
  5. Add en_GB as the fallback locale for this tree.

And here you already see the implementation issue. Your implementaiton in the button uses the fallback locale of step 5. But it should use the masterDefaultLocale from Step 4. This is what the LiveCopyMultiSiteI18nAuthoringSupport method is doing. 

Comment by Quach Hao Thien [ 01/Sep/21 ]

just double check:

4. Add en_US as masterDefaultLocale > should be masterLocale instead

Comment by Marvin Kerkhoff [ 01/Sep/21 ]

yes, sorry  i am just to deep in this shit.

Comment by Quach Hao Thien [ 06/Sep/21 ]

Hi marvink2,

sorry for late response, I was on holiday.

does this site definition below describe best your slave page?

Comment by Marvin Kerkhoff [ 07/Sep/21 ]

Welcome back.

masterLocale = en_US

defaultLocale need to be en_GB

fallbackLocale = en_GB

 

In the time where Jan and i have developed the module together we came across this stupid issue. It seems that there is a weird configuration. In some cases defaultLocale is used and in some fallbackLocale. The problem becomes even more difficult if you have a slave site configuration where you have no en_US Locale at all. 

Comment by Quach Hao Thien [ 07/Sep/21 ]

I found a problem with masterLocale.

the masterLocale datatype actually is a String, https://git.magnolia-cms.com/projects/ADDON/repos/live-copy/browse/src/main/java/info/magnolia/livecopy/i18n/LiveCopyI18nContentSupport.java#39, whereas the defaultLocale, or fallbackLocale have datatype as Locale. 

And when it is converted to Locale https://git.magnolia-cms.com/projects/ADDON/repos/live-copy/browse/src/main/java/info/magnolia/livecopy/i18n/LiveCopyMultiSiteI18nAuthoringSupport.java#54 

the Locale masterLocale = new Locale(masterLocaleString); will return a Locale with language "en_US", this is an invalid one, we expect to have a Locale with language as en and country as US. Therefore it cannot be used to check the default locale of slave page. 

To fix this issue, there are 2 ways:

  1. Change the line Locale masterLocale = new Locale(masterLocaleString); => Locale masterLocale = LocaleUtils.toLocale(masterLocaleString);
  2. Get rid of the masterLocale, we can know the defaultLocale of master page by using LiveCopyUtils.getMasterNode(slaveNode), ref here for more information:
    https://git.magnolia-cms.com/projects/ADDON/repos/live-copy/pull-requests/124/overview

I'm really appreciate if you could try one of these method above, and see if it works for you.

"In the time where Jan and i have developed the module together we came across this stupid issue. It seems that there is a weird configuration. In some cases defaultLocale is used and in some fallbackLocale. The problem becomes even more difficult if you have a slave site configuration where you have no en_US Locale at all." -> Indeed, there is no document about the defaultLocale, but as I investigated, the fallbackLocale is used only the defaultLocale is missing, therefore in any case we should prioritize defining defaultLocale.

Generated at Mon Feb 12 02:27:17 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.