| When a blog category is renamed, CategoryRenameListener restores the parent the category had before the rename. It restores it as an absolute reference, so the parent is now stored as xwiki:Blog.Categories.Parent instead of Blog.Categories.Parent. The category pages look for the subcategories of a category by comparing the stored parent with the local name of the category (doc.parent = :category in #renameCategory and #deleteCategory, Blog.CategoriesCode), as does the category location migration. A category that was renamed once is therefore no longer found as a subcategory of its parent. Steps to reproduce
- Create a category Parent and a subcategory Child of it
- Rename Child to Child2 (page rename)
- Rename Parent to Parent2 from Blog.ManageCategories, or delete it
Expected: Child2 is a subcategory of Parent2 (or of the parent of the deleted category) Actual: the parent of Child2 is not updated and still points to Parent, which doesn't exist anymore Cause CategoryRenameListener.java:117 keeps XWikiDocument#getParentReference(), which is always absolute, and CategoryRenameListener.java:141 sets it back as is. XWikiDocument#getParent(), which is what is saved in the database, then serializes it with the wiki. The relative parent (getRelativeParentReference()) should be kept instead. The current behaviour is pinned by CategoryRenameListenerTest#renamingACategoryKeepsItsParent (BLOG-269). |