Uploaded image for project: 'Blog Application'
  1. Blog Application
  2. BLOG-274

Renaming a blog category stores its parent with the wiki prefix

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 9.15.14
    • None
    • None
    • Unknown

    Description

      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

      1. Create a category Parent and a subcategory Child of it
      2. Rename Child to Child2 (page rename)
      3. 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).

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: