Fixed PHP 7 - arrays get concatenated in templates...

Mr. Goodie2Shoes

Well-known member
I know PHP 7 is still in beta and this might be an issue with PHP's interpreter rather than XenForo's template compiler but still wanted to post this.

Yesterday, I tried out PHP 7 and when I did a master rebuild I saw that all the links that have something like:
Code:
{xen:link something, '', '_params={$linkParams}'}
outputs something like:
Code:
something?_params=Array

I know that the array pushed inside '_params' gets extracted by XenForo_Link to append them in the query string rather than the one above.

So when I looked into the compiled template there was something like:
Code:
XenForo_Template_Helper_Core::link(htmlspecialchars($linkType, ENT_QUOTES, 'UTF-8'), $linkData, array(
'_params' => '' . $linkParams
))

I did the master rebuild twice and the issue persisted.
So I moved back to PHP 5.6 then did another master rebuild and the issue was resolved:
Code:
XenForo_Template_Helper_Core::link(htmlspecialchars($linkType, ENT_QUOTES, 'UTF-8'), $linkData, array(
'_params' => $linkParams
))
 
I have PHP7 set up in a VM I can test this on.

I haven't spotted this so far in my tests, but I'll check that specific case out.
 
So that's what's causing that issue, I though it was a bug in an add-on and/or I was going insane!

@Chris D the best place to see it is in page nav & the old resource tabs.

Liam
 
Thanks for posting a fix. I tried this on a 1.4.x installation, but I'm still getting ?_params=Array appended to forum page URLs. Are there any other modifications required?
 
Top Bottom