Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

User macro fails after update from 7.4 to 7.13



We used an own written macro with some velocity, some html, css and javascript. All worked well in version 7.4.7, but after the upgrade to 7.13.1 the macro does not work anymore. After a lot of debugging - I am not a developer - I am absolutely not able to find the reason. One problem is the javascript part: If I log the console output, it does what it should (set the display property of a div to block or hidden), but this change is not visible in the browser window - only the first occurency applies the change.

The other part is velocity itself. I created a simple macro to demonstrate the problem:



## Params

## @Param otherpage:title=Link to another page|type=confluence-content|required=true|desc=Link to another page
## @Param pageinclude:title=Link to page to be included|type=confluence-content|required=true|desc=Link to page to be included

## ------------------------------------------

<h3>set otherpage</h3>

#set( $linkotherpage = "<ac:link><ri:page ri:content-title='$paramotherpage' /><ac:plain-text-link-body><![CDATA[Here goes the dummy text]]></ac:plain-text-link-body></ac:link>" )

<h3>set includeline</h3>

#set ($includeline = "<ri:page ri:content-title='$parampageinclude' />")

<h3>output other page from var</h3>


<h3>output direct to other page</h3>

<ac:link><ri:page ri:content-title='Testpage Link' /><ac:plain-text-link-body><![CDATA[Here goes the dummy text]]></ac:plain-text-link-body></ac:link>

<h3>include page direct</h3>

<ac:structured-macro ac:name="include" ac:schema-version="1"><ac:parameter ac:name=""><ac:link><ri:page ri:content-title="Testpage Include" /></ac:link></ac:parameter></ac:structured-macro>

<h3>include page from var</h3>
<ac:structured-macro ac:name="include" ac:schema-version="1"><ac:parameter ac:name=""><ac:link>$includeline</ac:link></ac:parameter></ac:structured-macro>



If the links are set directly, they work. If they are set from a variable, they don't work and I have absolutely no idea why. The macro above demonstrates the behavior.

Any help or idea would be really appreciated.

Thanks and regards


1 answer

0 votes
Bill Bailey Community Leader Nov 09, 2021

My suggestion is to refresh your page, then check the logs to see what errors are logged at that time. Often, it will flag the issues to give you a chance at debug.

Thank you for the suggestion, but there are no errors. There is nothing logged at all if I refresh the page.

I set the log level of velocity to DEBUG and made some tests. There are several lines, but they remain the same, no matter if my macro is on the page or not. So I assume, that there is no log output from my macro.

It seems that as soon as there are chars like <, >, :, aso, in the variable, the rendering of it doesen't work anymore. This happens even in safe mode.

Bill Bailey Community Leader Nov 10, 2021

I notice that your variables are offset with single qoutes, but then later,  you where you are testing, you are surrounding the page name with double quotes.

Yes, you are right. But unfortunately, it makes no difference. When I pass the whole line into a variable, I have no choice beside using single quotes for the page name, as I am not able to escape double quotes (or I don't know how, because none of the ways I found online are working).

If I change the double quotes to single quotes - in the "direct testing" part - the result remains the same. So I assume for velocity it makes no difference if there are used single or double quotes.

I made some further thests: I can pass the $paramotherpage or $parampageinclude to other variables. As long as I don't use any special chars, it works. At least the velocity part.

Bill Bailey Community Leader Nov 11, 2021

Could you provide the rendered HTML, to see how the renderer is actually displaying the macro?

Sure, added as a jpeg. Thanks!

The page do be included contains the text "Diese Seite wird als Include angezeigt.".


Bill Bailey Community Leader Nov 11, 2021

Your "include page from var" references the variable "$includelineor1" but I don't see where it is defined. I see where "$includeline" is set, but not the other.

Oh, yes, you are right. I just corrected this in the macro (also in my text above). The result itself does not change as the whole part, which is contained in "$includeline" ("<ri:page ri:content-title='$parampageinclude' />") is not rendered. Therefore it includes the page itself where the macro is located at.

Bill Bailey Community Leader Nov 12, 2021

So when the macro fails to render, there is not a note in the log?

Why not structure this line:

<ac:structured-macro ac:name="include" ac:schema-version="1"><ac:parameter ac:name=""><ac:link>$includeline</ac:link></ac:parameter></ac:structured-macro>

To be the following instead?

<ac:structured-macro ac:name="include" ac:schema-version="1"><ac:parameter ac:name=""><ac:link><ri:page ri:content-title='$parampageinclude' /></ac:link></ac:parameter></ac:structured-macro>

Unfortunately not. Not a single line to this in the logs.

The whole macro would be much longer. There I split the page in two parts, if the page is in another space. So the construct of the link changes and therefore, I write the changing part in a variable. As it fails with the above example too, I did not mention it, because it would complicate the whole thing.

I think I will find other ways to achieve the goal, but in a more complicated and much longer way. I still don't know what changed that this does not work anymore. I even don't know if this only happens to me/us on our installation, or if it is the same behavior on all confluence installations (7.13.1 and above).

Bill Bailey Community Leader Nov 15, 2021

Unfortunately, Atlassian is not doing a great job supporting user macros, so there are no notifications when things change.

I would suggest trying to rebuild your macro starting with a blank page. Thier may some change in syntax that is hard to see.

Also, is there may be away to do this with java objects and methods, something like $page.getbodycontent (not sure that is correct, but you can search the API to find out for sure).

Thanks a lot for your help and your patience! For the velocity-part I found a solution. I just don't put the whole part of the link-code in the var, but just the page name or space name itself.

For the java script part - i just mentionned it but did not provide an example here - I found out that if the page (i.e. page A) with the macro is used as normal page, the javascript does not work correctly. If I include this page (page A) on another page (page B) and run the javascript on the other page (page B), it works as expected. So until I find a good solution, I just include the page (A) with the macro on another page (B) and it works. Somewhat special, but it is as it is...

Thanks again for your support!

A bit late, but may be it helps other guys reading this thread...

The solution for this problem can be found here. Confluence performs htmlencoding for every variable that is used as output, except the name of the variable ends with "Html". So in the discussed case here, name the variable "includelineHtml" instead of "includeline". That should work than.

Like # people like this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

348 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you