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

      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>
      

            [CONFSERVER-39582] Content by label macro migration is broken when converting a MacroDefinition to storage

            roman added a comment -

            Still reproducible with Confluence 6.15.1

            roman added a comment - Still reproducible with Confluence 6.15.1

            We have a lot of templates which use content-by-label, and as our teams create pages based on these, we keep having problems with broken pages. Please fix!!

            Nitza Hauser added a comment - We have a lot of templates which use content-by-label, and as our teams create pages based on these, we keep having problems with broken pages. Please fix!!

            I've found the same problem with a third-party vendor macro from Adaptavist's Page information plugin. If you put the following markup on a page and try to process the MacroDefinition with convertMacroDefinitionToStorage the XHTML is broken:

            <p>Here is some stuff</p><p><ac:structured-macro ac:name="page-info" ><ac:parameter ac:name="page">Page title</ac:parameter><ac:parameter ac:name="">title</ac:parameter></ac:structured-macro></p>
            

            You need to insert the markup via the database.

            Christoffer Bromberg (K15t) added a comment - I've found the same problem with a third-party vendor macro from Adaptavist's Page information plugin. If you put the following markup on a page and try to process the MacroDefinition with convertMacroDefinitionToStorage the XHTML is broken: <p>Here is some stuff</p><p><ac:structured-macro ac:name= "page-info" ><ac:parameter ac:name= "page" >Page title</ac:parameter><ac:parameter ac:name="">title</ac:parameter></ac:structured-macro></p> You need to insert the markup via the database.

            Unfortunately, we are experiencing this issue a lot on our large Enterprise instance.

            Please provide a fix on this bug, soon!

            Jens Kasperek (Bosch GmbH) added a comment - Unfortunately, we are experiencing this issue a lot on our large Enterprise instance. Please provide a fix on this bug, soon!

            roman added a comment -

            Also reproducible on 5.9.7

            roman added a comment - Also reproducible on 5.9.7

            I experimented with other macros, but did not find another problem like this, i.e. I took other macros that can be confined to a space like blog macro, content report macro, ... and tried if could achieve the same effect, but couldn't.

            I also tried it with the detailssummary macro (Page Properties Report), which will also get migrated to schema-version 2, but here the "spaces" parameter remained intact.

            Christoffer Bromberg (K15t) added a comment - - edited I experimented with other macros, but did not find another problem like this, i.e. I took other macros that can be confined to a space like blog macro, content report macro, ... and tried if could achieve the same effect, but couldn't. I also tried it with the detailssummary macro (Page Properties Report), which will also get migrated to schema-version 2, but here the "spaces" parameter remained intact.

              Unassigned Unassigned
              86c03cb56278 Christoffer Bromberg (K15t)
              Affected customers:
              22 This affects my team
              Watchers:
              18 Start watching this issue

                Created:
                Updated: