Issues

ZF-11340: Problem with method assemble() in /library/Zend/Controller/Router/Route/Module.php line 234 when params have an array with two levels

Issue Type: Bug Created: 2011-05-03T17:41:35.000+0000 Last Updated: 2011-05-03T17:41:35.000+0000 Status: Open Fix version(s): Reporter: Matthieu Chatel (matthieuchatel) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Controller_Router

  • zend_controller

Related issues: Attachments:

Description

I encounter this problem with the Paginator when i've url with params containing an array with two levels.

The error is : Warning: urlencode() expects parameter 1 to be string, array given in /library/Zend/Controller/Router/Route/Module.php on line 234

When I change the code source :

    foreach ($params as $key => $value) {
        $key = ($encode) ? urlencode($key) : $key;
        if (is_array($value)) {
            foreach ($value as $arrayValue) {
                $arrayValue = ($encode) ? urlencode($arrayValue) : $arrayValue;
                $url .= '/' . $key;
                $url .= '/' . $arrayValue;
            }
        } else {
            if ($encode) $value = urlencode($value);
            $url .= '/' . $key;
            $url .= '/' . $value;
        }
    }

by :

if ($encode) { $url .= '?'.http_build_query($params); } else { foreach ($params as $key => $value) { if (is_array($value)) { foreach ($value as $arrayValue) { $url .= '/' . $key; $url .= '/' . $arrayValue; } } else { $url .= '/' . $key; $url .= '/' . $value; } }
}

This solution is not perfect, do you have any other solution ?

Comments

No comments to display

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts