TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Kohana Request doesn't allow multiple values for query parameter
  • Some government webservice expects me to use a query string in this form: ?modified=[startdate]&modified=[enddate] , so it uses the modified parameter twice.

    Kohana Request object removes the second modified parameter, even if I provide the url string as a literal in the factory methode (that is, not using the query method).

    I can work around this (simply using file_get_contents), but I was wondering if this should be considered incorrect behaviour of the Request object.

  • Sendgrid has the same issue, I had hit a major roadblock when trying to do that with Sendgrid. I think the behaviour is correct, because I dont think its proper the way its setup, but I am not 100% sure on that.

  • The RFC document for URI's doesn't actually define a standard syntax for query strings, so it's really up to the client to interpret them however they want. With that said, I think the syntax you're looking for is actually ?modified[]=[startdate]&modified[]=[enddate]. You can test this with php's parse_str() function:

    parse_str('var=test1&var=test2',$output); var_dump($output); will output:

    array(1) { 'var' => string(5) "test2" }

    ...whereas parse_str('var[]=test1&var[]=test2',$output); var_dump($output); will output:

    array(1) { 'var' => array(2) { [0] => string(5) "test1" [1] => string(5) "test2" } }

    Since there's no formal standard, your government webservice isn't "wrong", per-se, but PHP definitely handles it differently, and thus so does Kohana.

  • Yeah PHP is very bad at handling query strings for both generation and parsing. I'm running into similar issues at work and will most likely try to make the Kohana classes friendlier for this kind of stuff but for now you'll just have to replace which ever call to parse_str and http_build_query that is causing you issues with a hand made function that does things the way you need.

  • @talisto

    thank you for your elaborate and clear comment. So it's actually a php thing and not a Kohana thing.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion