Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Zend\Uri\Uri::setQuery() should validate or cast values #5770

Closed
hschletz opened this issue Jan 31, 2014 · 3 comments
Closed

Zend\Uri\Uri::setQuery() should validate or cast values #5770

hschletz opened this issue Jan 31, 2014 · 3 comments

Comments

@hschletz
Copy link
Contributor

Zend\Uri\Uri::setQuery() passes array arguments directly to http_build_query(), which silently discards values which it regards to be invalid. This can cause unexpected behavior, like this:

class foo
{
    public function __toString()
    {
        return 'bar';
    }
}
$uri->setQuery(array('foo' => new foo));
// We'd expect the object to behave like a string and yield 'foo=bar', but we get '' instead

setQuery() should either validate each argument and fail if http_build_query() would treat it in an unexpected way (i.e. silently discard), or try to cast it to a string, which would cause an error if that is not possible.

@Ocramius
Copy link
Member

Ocramius commented Apr 3, 2014

@hschletz as far as I know, http_build_query uses (array) casting on passed in objects (see this article /cc @FrozenFire).

It doesn't really discard anything.

@hschletz
Copy link
Contributor Author

OK, this is a documentation issue. I opened a new issue as zendframework/zf2-documentation#1253.

As I think about it, I don't see a reliable fix for the inherent ambiguity of passing objects other than better documentation.

@GeeH
Copy link

GeeH commented Jun 27, 2016

This issue has been closed as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html

@GeeH GeeH closed this as completed Jun 27, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants