Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-39582

Content by label macro migration is broken when converting a MacroDefinition to storage

    XMLWordPrintable

Details

    Description

      When you have a non-migrated macro definition of a contentbylabel parsed to a MacroDefinition object and then call XhtmlContent.convertMacroDefinitionToStorage the returned XHTML is broken.

      In our case we get the page content in the transformer chain "storage to editor" and have to convert the macro body of our own macro back to Xhtml so it can be processed by later parts of the chain.
      When the editor content then is saved the broken macro definition is then stored to the page and when you return to viewpage.action, the macro can't be rendered anymore.

      You can easily construct the case with some code (have a debugger in the transformation chain to try it out). The MacroDefinition object is what I get from Confluence within a MacroDefinitionReplacer:

      Test.java
      MacroDefinition contentByLabel = new MacroDefinition(new MacroDefinitionBuilder().withName("contentbylabel").withParameter("label", "some").withTypedParameter("label", "some").withParameter("spaces", "test").withTypedParameter("spaces", new SpaceResourceIdentifier("test")).withStorageVersion("2").withSchemaVersion(1));
      String xhtmlString = xhtmlContent.convertMacroDefinitionToStorage(contentByLabel, new DefaultConversionContext(context.getEntity().toPageContext()));
      

      The StorageMacroV2Marshaller messes up the representation of the space resource identifier. That's what it looks like:

      <ac:structured-macro ac:name="contentbylabel" ac:schema-version="2" ac:macro-id="06af8213-3f7c-4877-b493-c521616fad10"><ac:parameter ac:name="label">some</ac:parameter><ac:parameter ac:name="spaces">com.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@364492</ac:parameter><ac:parameter ac:name="cql">label = "some" and space = "test"</ac:parameter></ac:structured-macro>
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            86c03cb56278 Christoffer Bromberg (K15t)
            Votes:
            22 Vote for this issue
            Watchers:
            18 Start watching this issue

            Dates

              Created:
              Updated: