Affects Version/s: 7.0.X EE, Master
Component/s: Dynamic Data Mapping > Upgrades
In Liferay 6.1 and earlier, you were allowed to have duplicate field names in your structures. However, starting with Liferay 6.2, you are no longer allowed to have duplicate field names in your structures. If you try to upgrade from Liferay 6.1 to Liferay 6.2 while having structures with duplicate field names, the upgrade process will fail. Normally, we recommend that clients run a NormalizeDuplicateFields groovy script in Liferay 6.1 prior to upgrading to a later version (see https://customer.liferay.com/documentation/knowledge-base/-/kb/34622 for more information).
However, if you try to upgrade from Liferay 6.1 directly to DXP while having structures with duplicate field names, the upgrade process will succeed. This is because the process which checks to see if you have structures with duplicate field names was moved from a core verify process to a module verify process. So, you will see errors in the logs indicating that the DDMServiceVerifyProcess failed, but the upgrade will still proceed to completion.
What makes this bug particularly dangerous is that it causes significant data loss. The JournalServiceVerifyProcess also runs during the upgrade process. The JournalServiceVerifyProcess expects every structure to have unique field names. If a structure has a parent and child element of the same name, the JournalServiceVerifyProcess will completely mangle the xml for all of that structures' web content articles, to the point where the only way to restore the original content of those articles is to use a backup of the database from before the upgrade. There may be other cases for which the xml will get mangled, but I have not tested them yet.
Another case in which the xml can get completely mangled is if a structure's field name had spaces in it in Liferay 6.1. In this case, after the upgrade completes, all web content articles that use that structure will have their data completely erased for the fields whose names had spaces in them. This happens regardless of whether or not that structure had duplicate field names. This is another severe bug that needs to be looked into. In fact, I would expect that any structure field which has a character listed in the _INVALID_FIELD_NAME_CHARS_REGEX to be susceptible to this bug, since the name gets updated in the structure definition but not in the corresponding web content articles.
The fix will be to move the validation logic for DDM Structures out of the verify process and place it in an upgrade process instead, so that the upgrade process fails if you have structures with duplicate field names.
Steps to Reproduce
1. In 6.1.20, go to Web Content Structure and add one that has a duplicate field name:
- Mother name (Text):
- other (Text):
- Father name (Text):
- other (Text):
2. Add some web content articles with this structure.
3. Upgrade to Liferay DXP.
Expected Result: The upgrade process fails with an error message indicating that you cannot proceed because you have structures with duplicate field names.
Actual Result: An exception is thrown during the upgrade process, but it still finishes successfully. Every time you try to start up the portal, you will see the same exception. Moreover, if you look at the web content articles you added in step 2, you will find that they are completely broken.