-
-
Notifications
You must be signed in to change notification settings - Fork 773
[Bug]: TabController.DeleteTab with deleteDescendants fails to delete the passed tab #6438
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
When calling DeleteTab(tabId, portalId, true) you would expect the descendants to get deleted as well as the tab associated with the passed tabId. However, the call fails to do so on the initial call to the method. On subsequent calls, when no children remain after being deleted from the first call, the passed tab does get deleted.
Steps to reproduce?
- Call
DeleteTabon an instance ofTabControllerwhile passing the overloaddeleteDescendantsas true. - Check to see if the tab passed into the
DeleteTabcall has been deleted. It will not be. - Call
DeleteTabon an instance ofTabControlleragain and verify that this time the tab has actually been deleted.
Current Behavior
At first glance, the cause seems to be related to caching and the order of operations. When calling the method with the overload, it first gets all descendant tabs and caches them.
public void DeleteTab(int tabId, int portalId, bool deleteDescendants)
{
List<TabInfo> descendantList = this.GetTabsByPortal(portalId).DescendentsOf(tabId);
if (deleteDescendants && descendantList.Count > 0)
{
// Iterate through descendants from bottom - which will remove children first
for (int i = descendantList.Count - 1; i >= 0; i += -1)
{
this.HardDeleteTabInternal(descendantList[i].TabID, portalId);
}
}
this.DeleteTab(tabId, portalId);
}
At the end of the method it calls the DeleteTab method without the overload, which first checks for descendants and only deletes when no descendants exist. I don't think the cache has been cleared at this point, so descendants are found and the tab isn't deleted. Then the cache gets cleared, allowing for subsequent calls to work.
public void DeleteTab(int tabId, int portalId)
{
// parent tabs can not be deleted
if (this.GetTabsByPortal(portalId).WithParentId(tabId).Count == 0)
{
this.HardDeleteTabInternal(tabId, portalId);
}
this.ClearCache(portalId);
}
Expected Behavior
I would expect the initial call to clear the cache prior to calling to delete the main passed tab, or for the methods to not utilize a cache at all when determining descendants. Either way, I would expect a single call with the overload as true to delete the passed tab as well as descendants.
Relevant log output
Anything else?
No response
Affected Versions
9.13.7 (latest release), 10.0.0 (RC), 9.13.8 (RC)
What browsers are you seeing the problem on?
No response
Code of Conduct
- I agree to follow this project's Code of Conduct