1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Resolved Bug Reports' started by Mr. Goodie2Shoes, Jul 22, 2015.

  1. Mr. Goodie2Shoes

    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:
    {xen:link something, '', '_params={$linkParams}'}
    outputs something like:
    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:
    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:
    XenForo_Template_Helper_Core::link(htmlspecialchars($linkType, ENT_QUOTES, 'UTF-8'), $linkData, array(
    '_params' => $linkParams
  2. Chris D

    Chris D XenForo Developer Staff Member

    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.
  3. Liam W

    Liam W Well-Known Member

    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.

  4. Mike

    Mike XenForo Developer Staff Member

    This is fixed now (for 1.5). Specifically, this was caused by a behavior change in substr. There was a situation where it used to return false where it now returns an empty string.
    DroidOne, Mr. Goodie2Shoes and Liam W like this.
  5. Jeremy P

    Jeremy P Well-Known Member

    Came across this on 1.4.12.

    If anyone needs it, I fixed it by editing library/XenForo/Template/Compiler.php line 811 to:
                if ($nameRemoved === false || $nameRemoved === '')
    thedude, lsxforo, nrep and 3 others like this.
  6. nrep

    nrep Well-Known Member

    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?
  7. Liam W

    Liam W Well-Known Member

    You'll need to recompile the templates. Go to /install on your XenForo and use the rebuild master data button.

    thedude, lsxforo and nrep like this.
  8. nrep

    nrep Well-Known Member

    Brilliant! Thanks Liam, that did the trick :).

Share This Page