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

By hiroko - March 20, 2018 - edited: March 20, 2018

Hello,

I am receiving an error log for the permalink I set manually.

E_WARNING: urlencode() expects parameter 1 to be string, array given

filepath: /cmsAdmin/plugins/permalinks1_05/permalinks_dispatcher.php

Line Num: 104

The original url is

/article-category.php?article_category=13&article_category_list[]=tips&article_category_list[]=archive

and the permalink is

/feature/

The permalink itself is working fine on the browser but I receive the error message every time I load the page.

I tried without using [] but it wouldn't give me the correct result.

What do I need to do to correct this?

Thanks in advance.

Hiroko

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