Skip to content

The tasks inside other macros are not assigned a reference if it's parent is a sibling of certain elements #45

@trrenty

Description

@trrenty

Steps to reproduce:

  1. Add the following or similar content to a page
{{tip}}
Hello
{{/tip}}

----

{{info}}
{{task createDate="2023/07/02 09:43" reporter="XWiki.superadmin" reference="TEOS.TeoSpace Home.Task_0"}}
ffasadas
{{/task}}
{{/info}}
  1. Save and view the page

Expected results:
The added task will have an id and reference assigned and therefore will display a link to the created page.
Actual results:
The task doesn't have a reference or id.

This happens because the listener that assigns the reference will search for tasks recursively inside the content of all the macros that support XWiki syntax. When detecting a new task, it will add some new parameters and possibly a new content. To change the content, we need to replace the task with a clone of it. This will change the content of it's parent. We take the list of children of the parent, we delete our task using it's index and replace it with the clone. The problem is with finding the index. Using the list.indexOf() function will throw an exception. At some point in time, it will call the AbstractMacroBlock.equals(otherMacro) function that will cast the otherMacro to AbstractMacroBlock. In our specific example, the dashed line ---- is a HorizontalLineBlock which is not an instance of AbstractMacroBlock.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions