-
Notifications
You must be signed in to change notification settings - Fork 3.7k
LPD-69423 highlight sidebar menu correctly #6698
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,10 @@ | |
| package com.liferay.site.cms.site.initializer.internal.util; | ||
|
|
||
| import com.liferay.depot.model.DepotEntry; | ||
| import com.liferay.depot.service.DepotEntryLocalServiceUtil; | ||
| import com.liferay.info.constants.InfoDisplayWebKeys; | ||
| import com.liferay.object.model.ObjectEntry; | ||
| import com.liferay.object.model.ObjectEntryFolder; | ||
|
|
||
| import jakarta.servlet.http.HttpServletRequest; | ||
|
|
||
|
|
@@ -23,6 +25,11 @@ public static long getDepotEntryId(HttpServletRequest httpServletRequest) { | |
| DepotEntry depotEntry = | ||
| object instanceof DepotEntry ? (DepotEntry)object : null; | ||
|
|
||
| if (depotEntry == null) { | ||
| depotEntry = DepotEntryLocalServiceUtil.fetchGroupDepotEntry( | ||
| getGroupId(httpServletRequest)); | ||
|
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Consider adding a check for null after calling if (depotEntry == null) {
depotEntry = DepotEntryLocalServiceUtil.fetchGroupDepotEntry(
getGroupId(httpServletRequest));
if (depotEntry == null) {
// Log an error or throw an exception
// Example:
// throw new Exception("No DepotEntry found for group " + getGroupId(httpServletRequest));
return 0; // Or throw an exception
}
} |
||
| } | ||
|
|
||
| if (depotEntry != null) { | ||
| return depotEntry.getDepotEntryId(); | ||
| } | ||
|
|
@@ -48,6 +55,14 @@ public static long getGroupId(HttpServletRequest httpServletRequest) { | |
| return objectEntry.getGroupId(); | ||
| } | ||
|
|
||
| ObjectEntryFolder objectEntryFolder = | ||
| object instanceof ObjectEntryFolder ? (ObjectEntryFolder)object : | ||
| null; | ||
|
|
||
| if (objectEntryFolder != null) { | ||
| return objectEntryFolder.getGroupId(); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test method
testGetPropslacks proper cleanup after execution. Specifically, theObjectEntryFoldercreated within the test is not deleted, which can lead to data pollution and potential interference with other tests. This can cause intermittent test failures and make the test suite unreliable.Consider adding code to delete the created
ObjectEntryFolderin afinallyblock or using a@Afterannotated method to ensure cleanup even if the test fails.