{"action":"created","issue":{"url":"https://api.github.com/repos/guzzle/guzzle/issues/2149","repository_url":"https://api.github.com/repos/guzzle/guzzle","labels_url":"https://api.github.com/repos/guzzle/guzzle/issues/2149/labels{/name}","comments_url":"https://api.github.com/repos/guzzle/guzzle/issues/2149/comments","events_url":"https://api.github.com/repos/guzzle/guzzle/issues/2149/events","html_url":"https://github.com/guzzle/guzzle/issues/2149","id":362581723,"node_id":"MDU6SXNzdWUzNjI1ODE3MjM=","number":2149,"title":"Query request option not merged with default value","user":{"login":"wouterj","id":749025,"node_id":"MDQ6VXNlcjc0OTAyNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/749025?v=4","gravatar_id":"","url":"https://api.github.com/users/wouterj","html_url":"https://github.com/wouterj","followers_url":"https://api.github.com/users/wouterj/followers","following_url":"https://api.github.com/users/wouterj/following{/other_user}","gists_url":"https://api.github.com/users/wouterj/gists{/gist_id}","starred_url":"https://api.github.com/users/wouterj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wouterj/subscriptions","organizations_url":"https://api.github.com/users/wouterj/orgs","repos_url":"https://api.github.com/users/wouterj/repos","events_url":"https://api.github.com/users/wouterj/events{/privacy}","received_events_url":"https://api.github.com/users/wouterj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-21T11:53:28Z","updated_at":"2018-09-21T13:00:27Z","closed_at":null,"author_association":"NONE","body":"| Q            | A\r\n| ------------ | ---\r\n| Bug?         | yes\r\n| New Feature? | no\r\n| Version      | 6.3.3\r\n\r\n#### Steps to Reproduce\r\n\r\n```php\r\n<?php\r\n\r\n$client = new \\GuzzleHttp\\Client([\r\n    'base_uri' => 'https://maps.googleapis.com',\r\n    'query' => [\r\n        'key' => '...google api key...'\r\n    ],\r\n]);\r\n\r\n$response = $client->get('/maps/api/distancematrix/json', [\r\n    'query' => [\r\n        'origins' => implode('|', $origins),\r\n       // ...\r\n    ],\r\n]);\r\n```\r\n\r\n#### Actual Behavior\r\n\r\nA request to:\r\n```\r\nGET https://maps.googleapis.com/maps/api/distancematrix/json?origins=some|cities\r\n```\r\n\r\n#### Expected Behavior\r\n\r\nA request to:\r\n```\r\nGET https://maps.googleapis.com/maps/api/distancematrix/json?key=googleKey&origins=some|cities\r\n```\r\n\r\n#### Possible Solutions\r\n\r\nhttps://github.com/guzzle/guzzle/blob/c7faf23816251ca3f35463c55f3178a9b60128fc/src/Client.php#L235-L236\r\n\r\nI understand that most options are shallow merged and fully deep merging of query parameters is also unwanted (i.e. #1452 ).\r\n\r\nI think what should be done is shallow merging the query option on it's own, i.e.:\r\n\r\n```diff\r\n+ if (isset($defaults['query']) && isset($options['query'])) {\r\n+     $options['query'] = $options['query'] + $defaults['query'];\r\n+ }\r\n \r\n  $result = $options + $defaults;\r\n```"},"comment":{"url":"https://api.github.com/repos/guzzle/guzzle/issues/comments/423522735","html_url":"https://github.com/guzzle/guzzle/issues/2149#issuecomment-423522735","issue_url":"https://api.github.com/repos/guzzle/guzzle/issues/2149","id":423522735,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzUyMjczNQ==","user":{"login":"sagikazarmark","id":1226384,"node_id":"MDQ6VXNlcjEyMjYzODQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1226384?v=4","gravatar_id":"","url":"https://api.github.com/users/sagikazarmark","html_url":"https://github.com/sagikazarmark","followers_url":"https://api.github.com/users/sagikazarmark/followers","following_url":"https://api.github.com/users/sagikazarmark/following{/other_user}","gists_url":"https://api.github.com/users/sagikazarmark/gists{/gist_id}","starred_url":"https://api.github.com/users/sagikazarmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagikazarmark/subscriptions","organizations_url":"https://api.github.com/users/sagikazarmark/orgs","repos_url":"https://api.github.com/users/sagikazarmark/repos","events_url":"https://api.github.com/users/sagikazarmark/events{/privacy}","received_events_url":"https://api.github.com/users/sagikazarmark/received_events","type":"User","site_admin":false},"created_at":"2018-09-21T13:00:27Z","updated_at":"2018-09-21T13:00:27Z","author_association":"CONTRIBUTOR","body":"I'm not sure that's the expected behavior with query parameters. With your proposal it would be impossible to not send certain query parameters without overriding it.\r\n\r\nIf you need this kind of behavior, I would suggest implementing a custom middleware which adds the query parameter to each request. That way you can even enforce accidental overwrites of the parameter by always setting it to a specific value in the middleware."}}
{"actor":{"display_login":"sagikazarmark"}}