URL params fatal error under PHP 8
-
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=GoldVisiting 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=GoldOr…
?material[]=GoldWorks fine, and applies the Algolia filters as expected. This even works when setting multiple values for ‘material’. I.e.
?material=Gold&material=SilverOr even…
?material[]=Gold&material[]=SilverGiven 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!
The topic ‘URL params fatal error under PHP 8’ is closed to new replies.