Permalink error: urlencode() expects parameter 1 to be string

By Dave - March 23, 2018

Hi Hiroko, 

Can you try upgrading to the latest Permalinks plugin and let me know if the issue still occurs? If so we can debug it and get you a patch.

Let me know, thanks!

Dave Edis - Senior Developer
interactivetools.com

By hiroko - March 25, 2018

Hi Dave,

Thanks for your reply.

I upgraded my permalink plugin to the latest ver.1.08 but I still get the error message.

The CMSbuilder is still v3.08. Would this be a problem?

E_WARNING: urlencode() expects parameter 1 to be string, array given
.../cmsAdmin/plugins/permalinks1_08/permalinks.php (line 302)
https://www.tokyoartantiques.com/feature/

Hiroko

By Dave - April 5, 2018

Hi Hiroko, 

Sorry for the delay.  I've located the source of this issue.  Can you try this patch in permalinks.php?

Search for $namesToValues and replace this code: 

    foreach ($namesToValues as $name => $value) {
      $_GET[$name]              = $value;
      $_REQUEST[$name]          = $value;
      $_SERVER['QUERY_STRING'] .= "&$name=" . urlencode($value);
    }

With this code:

    // create _GET/_REQUEST values
    foreach ($namesToValues as $name => $value) {
      $_GET[$name]              = $value;
      $_REQUEST[$name]          = $value;
    }
    
    // create QUERY_STRING
    $_SERVER['QUERY_STRING'] = http_build_query($namesToValues, null, '&');
    $_SERVER['QUERY_STRING'] = preg_replace('/(%5B|\[)\d+(\]|%5D)/i', '[]', $_SERVER['QUERY_STRING']); // replace name%5B0%5D, name%5B1%5D with name[], name[]

Let me know if that resolves the issue for you.

Dave Edis - Senior Developer
interactivetools.com

By hiroko - April 15, 2018

Hello Dave,

It worked!!

Thank you!!

Hiroko