Fixed Default template parameters not available in API requests

AddonsLab

Well-known member
Affected version
2.2.7 Patch 1
Some API requests render templates, for example, /nodes endpoint renders the content of Page nodes. If these pages happen to use variables otherwise available in templates, e.g. $xf.visitor the variables are not available and may also log an error if a method is called, e.g. $xf.visitor.canStartConversation().

To reproduce the issue create any Page node with the following content:

Code:
Hello {$xf.visitor.user_id}!

The expected outcome is "Hello 0!", the actual outcome is "Hello !".

The reason the variables are missing is that App::getGlobalTemplateData() method is never called in API requests and its output is not added to the default template parameters.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.8).

Change log:
Add global template data to the API templater
There may be a delay before changes are rolled out to the XenForo Community.
 
Top Bottom