[PEAR-BUG] Req #20427 [Fbk->Ver]: Option to not add numeric array keys in URL

[email protected] Fri, 17 Oct 2014 06:38:34 +0100 (BST)
Newsgroups php.pear.bugs
Message-ID <[email protected]>
Edit report at https://pear.php.net/bugs/bug.php?id=20427&edit=1

 ID:               20427
 Updated by:       [email protected]
 Reported By:      cweiske at php dot net
 Summary:          Option to not add numeric array keys in URL
-Status:           Feedback
+Status:           Verified
 Type:             Feature/Change Request
 Package:          Net_URL2
 Package Version:  2.0.10
 PHP Version:      Irrelevant
 Assigned To:      tkli
 Roadmap Versions: 
 New Comment:

-Status: Feedback
+Status: Verified
Yes, this option would be fine.


Previous Comments:
------------------------------------------------------------------------

[2014-10-17 02:44:26] tkli

-Status: Assigned
+Status: Feedback


------------------------------------------------------------------------

[2014-10-17 02:43:12] tkli

this can be done as a two line change for auto-detecting zero-based
sequences.

as auto-detecting it would modify the current behaviour, but as far as
parsing the query-info part 
parsing like PHP does is concerned, this wouldn't make a difference.

I suggest to not introduce an option but just change the behaviour.

an option would be naturally possible, too.

I suggest OPTION_DROP_SEQUENCE default being TRUE. When set to FALSE the
previous behaviour 
can be re-established.

------------------------------------------------------------------------

[2014-10-17 02:16:55] tkli

-Assigned To:
+Assigned To: tkli


------------------------------------------------------------------------

[2014-10-17 02:16:42] tkli

This should be equally the same in PHP, shouldn't it? So perhaps the
current behaviour could even 
qualify as a bug?

In review of 

    $url = new Net_URL2('http://example.org/?foo[]=bar&foo[]=baz');
    $variables = $url->getQueryVariables();

this is even inconsistent.

As you ask for an option - are you looking for an option passed in the
ctor array (which name would 
you suggest?) or for a flag you pass as an additional parameter to
Net_URL2::setQueryVariables?

------------------------------------------------------------------------

[2014-10-15 12:55:03] cweiske

Description:
------------
When working with some ruby servers, we need to send 
multiple values of the same 
parameter in the following manner:

http://example.org/?foo[]=bar&foo[]=baz

Adding a query parameter "foo" with value "array('bar', 'baz')" 
gives the following URL:

http://example.org/?foo[0]=bar&foo[1]=baz

I'd like to see a new option in Net_URL2 which activates my 
desired behavior.


Test script:
---------------
<?php
require_once 'Net/URL2.php';
$url = new Net_URL2('http://example.org/');
$url->setQueryVariables(array('foo' => array('bar', 'baz')));
echo (string) $url . "\n";
?>


Expected result:
----------------
http://example.org/?foo[]=bar&foo[]=baz


Actual result:
--------------
http://example.org/?foo[0]=bar&foo[1]=baz

------------------------------------------------------------------------


-- 
Edit this bug report at https://pear.php.net/bugs/bug.php?id=20427&edit=1