Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

User macro fails after update from 7.4 to 7.13

NKS November 9, 2021

Hi

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>

$linkotherpage

<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

NKS

1 answer

0 votes
Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 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.

NKS November 10, 2021

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 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.

NKS November 10, 2021

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2021

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

NKS November 11, 2021

Sure, added as a jpeg. Thanks!

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

render.jpg

Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 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.

NKS November 11, 2021

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 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>
NKS November 14, 2021

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 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).

NKS November 16, 2021

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!

Matthias Damsch January 27, 2022

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
DEPLOYMENT TYPE
SERVER
VERSION
7.13.1
TAGS
AUG Leaders

Atlassian Community Events