-
Type:
Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: 7.1.X, 7.2.X
-
Fix Version/s: 7.1.X, 7.2.10 DXP FP11, 7.2.10.3 DXP SP4, 7.2.X
-
Component/s: Categories
-
Branch Version/s:7.2.x, 7.1.x
-
Backported to Branch:Committed
-
Fix Priority:3
Steps to Reproduce
- Start up Liferay connected to a MySQL database
- Sign in as admin
- Navigate to Control Panel > Configuration > Server Administration
- Go to the Script tab
- Run the following Groovy script:
import com.liferay.asset.kernel.service.AssetVocabularyLocalServiceUtil; import com.liferay.asset.kernel.service.AssetCategoryLocalServiceUtil; import com.liferay.portal.kernel.model.GroupConstants import com.liferay.portal.kernel.service.GroupLocalServiceUtil import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.util.PortalUtil import com.liferay.portal.kernel.util.StringUtil import java.util.concurrent.Executors; userId = PortalUtil.getUserId(actionRequest); companyId = PortalUtil.getCompanyId(actionRequest); groupId = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST).getGroupId() serviceContext = new ServiceContext() vocabularyName = "Groovy_TestVocabulary" vocabulary = AssetVocabularyLocalServiceUtil.fetchGroupVocabulary(groupId, "Groovy_TestVocabulary") if (vocabulary == null) { vocabulary = AssetVocabularyLocalServiceUtil.addVocabulary(userId, groupId, vocabularyName, serviceContext); } AssetCategoryLocalServiceUtil.addCategory(userId, groupId, "cat-" + StringUtil.randomString(5) + "-" + StringUtil.randomId(5), vocabulary.getVocabularyId(), serviceContext); category = AssetCategoryLocalServiceUtil.addCategory(userId, groupId, "cat-" + StringUtil.randomString(5) + "-" + StringUtil.randomId(5), vocabulary.getVocabularyId(), serviceContext); AssetCategoryLocalServiceUtil.addCategory(userId, groupId, "cat-" + StringUtil.randomString(5) + "-" + StringUtil.randomId(5), vocabulary.getVocabularyId(), serviceContext); // Introduce duplicate left/right category ids to tree category.setLeftCategoryId(1); category.setRightCategoryId(2); AssetCategoryLocalServiceUtil.updateAssetCategory(category); // Add new category - Expected to detect broken tree and rebuild AssetCategoryLocalServiceUtil.addCategory(userId, groupId, "cat-" + StringUtil.randomString(5) + "-" + StringUtil.randomId(5), vocabulary.getVocabularyId(), serviceContext);
- Inspect the AssetCategory table in the database
- Check the various rows in the AssetCategory table, and assert that some rows are showing duplicate leftCategoryId and rightCategoryId as the previous entry.
Actual Behavior
Rows are showing duplicate leftCategoryId and rightCategoryId in multiple rows.
Expected Behavior
Rows should have unique leftCategoryId and rightCategoryIds.
- is related to
-
LPS-125083 Duplicate left/right categoryId entries are added when creating asset categories
- Closed