• Resolved fabregas4

    (@fabregas4)


    When routing = true or using custom routing (stateToRoute/routeToState) a fatal error occurs (under WP with PHP8) for refinementList.

    Adding a refinementList refinement, results in the URL updating to something like this:

    ?material%5B0%5D=Gold

    Visiting this URL directly (or hitting refresh) results in a PHP fatal error. Digging into it, it seems like WP is detecting ‘material’ as being the same name as a WordPress taxonomy and it tries to do some parsing on it, resulting in calling wp_basename() but with the first argument being an array (i.e. $material[0] = “Gold”).

    wp_basename() calls PHP’s urlencode with this argument. Under PHP8, calling urlencode with an array causes a fatal error.

    The frustrating thing about this is that accessing either the URL:

    ?material=Gold

    Or…

    ?material[]=Gold

    Works fine, and applies the Algolia filters as expected. This even works when setting multiple values for ‘material’. I.e.

    ?material=Gold&material=Silver

    Or even…

    ?material[]=Gold&material[]=Silver

    Given this works, how can we get Instantsearch to update the URL to this format, rather than the URL encoded one with %5B0%5D in it, resulting in not only a more user-friendly URL, but avoiding the PHP fatal error in WordPress?

    Or any other suggestions for workarounds? The only one I can think of is forcing url param names to be slightly different to actual WP taxonomy names within stateToRoute/routeToState.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hmm,

    Very interesting and I’m not sure how to potentially reproduce locally either.

    I’m trying to think of how/why the generated URL is hitting your server instead of doing the request to Algolia. Or is this happening after information is coming back from Algolia?

    Do you have a URL where I can see this in action?

    Thread Starter fabregas4

    (@fabregas4)

    When visiting a URL, the page is first served up by the server (i.e. PHP/Wordpress). If the URL contains params in this url encoded format, and a param name matches a WordPress taxonomy name, there is a fatal error before the page is even served. As such it doesn’t even get as far as Algolia loading on the client-side.

    Any way I can DM you a URL on here? I don’t really want a client website URL on this forum.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    You can email the URL via our contact form at https://pluginize.com/contact/ and I’ll be able to retrieve it there.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Pending further discovery via private correspondence. Will report back when able

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘URL params fatal error under PHP 8’ is closed to new replies.