How to reproduce
- Create a course with a test
- Add a group to the test
- Open Assessment tool
- Select "Groups" in the segments navigation
- Select a specific group in the group list
- Now, got system administration
- Open System -> Caches
- Clear the "CourseFactory" cache
- Select the still opened course in the top navigation
- Select a course node in the left menu
- => NOK: error shows up that the course node has been deleted (which is not the case)
The problem can be traced down to TreeHelper.findNodeByUserObject() where the the two nodes are compared using
The problem is that userObject is the node loaded from the (newly loaded) course while node is the one taken from the menu tree user object. They represent the same object, but have different object identities.
A solution could be to override GenericNode.equals() method with something that returns true for objects where node.getIdent() is the same. However, this could have severe side effects, it is unclear if there is code that builds upon the fact that the equals method is not implemented.
Another solution could be to check if the user object is of type INode and if so cast and compare the ident of the two objects instead of the object identity.
The bug could also be responsible for other, not reproduceable strange errors that happen in the context of menu trees objects.