drupal_http_request() currently encodes request data with http_build_query(). It would be better to use drupal_http_build_query().
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | drupal-use_drupal_http_build_query-3059391-2-D7.patch | 2.7 KB | liam morland |
| #9 | drupal-use_drupal_http_build_query-3059391-9-D7-tests-only.patch | 1.09 KB | liam morland |
Comments
Comment #2
liam morlandPHP 5.3 failure is in the branch result.
Comment #3
polHi Liam,
Do you mind explaining why we would need drupal_http_build_query() instead of http_build_query() ?
I see in the documentation that the difference are:
Do you mind let us know why we should change ? It worked like this since ages... why this sudden change now ?
Comment #4
liam morlandUntil Drupal 7.67, the only place http_build_query() appeared was in the documentation. The first time I used the ability to pass in an array instead of a string, it didn't work because the server required a RFC 3986-compliant request instead of the RFC 1738-compliant request that is generated by http_build_query(). Only when I was investigating the problem did I learn of the existence of drupal_http_build_query().
People having this problem in the past are unlikely to file a bug against the documentation. They'll just use drupal_http_build_query() or the enc_type parameter to http_build_query() (which we can't use because Drupal still supports PHP < 5.4).
Comment #5
polFair enough :-)
I will move this things forward.
Comment #6
fabianx commentedAs this is a bug and tests are changed, this will need a test.
Comment #7
liam morlandWhat more needs to be tested? The test is already updated to test for the problem.
Comment #8
polHi Liam,
I had a talk with Fabian.
Fabian meant that you should provide a patch only with a test that is failing, and then, another patch with your changes and tests should pass.
Comment #9
liam morlandTests-only patch.
Comment #10
polThanks Liam !
I think it would have been nice to create a new tests that is failing without any code modification.
Then, include that new test in the final patch that will contain the code update AND the tests.
Comment #12
liam morlandOK. I'll do it that way next time. The patch in #2 is the test in #9 plus the fix.
Comment #13
polHi Liam,
Any news on this ?
Comment #14
liam morlandThe patch in #9 is just the failing tests. The patch in this issue is just the fix. Is that what you need?
Comment #15
ciss commented@Liam Morland your final patch should include both the fix and the tests.
The first tests-only patch is only needed to verify that the tests will catch the problem. The final patch (which includes the tests) is the one that will be committed.
Comment #16
liam morlandThe combined patch is in #2.
Comment #17
ciss commentedHiding and reordering files to bring #2 to the top.
Comment #18
liam morlandHas tests.
Comment #19
fabianx commented#2 is pending Drupal 7 commit.
I missed that we just recently introduced http_build_query().
That changes the scope definitely.
Comment #20
joseph.olstadTo increase our confidence in the test results for the above issue, these two should go in first so we can re-queue php 7.3 and php 5.3 tests.
#3047844: [Regression] Tests fail on PHP 5.3
#3025335: session_id() cannot be changed after session is started
Comment #21
mcdruid commentedThis info is already in this issue, but I also didn't pick up the full context / backstory initially.
To make it really explicit; we introduced support for passing data as an array to
drupal_http_request()fairly recently in #2814031: In drupal_http_request(), allow passing data as array (which is already marked as the parent of this issue).However, as @Liam Morland pointed out in #19 of that issue:
So what we're doing in this issue is fixing that oversight.
The patch (#2) looks good to me, but one thing I wasn't sure about in the changes to the test:
I can see we're adding a space character because the two different functions will encode that differently, but why are we adding the two types of quotes to the end of the value here?
Doesn't look like they do any harm, I'm just curious whether I'm missing a reason why we need to add them?
Also, PHP 7.3 tests should pass now, so I'll queue a retest.
Comment #22
mcdruid commentedComment #23
liam morlandIt was a while ago. I think the quotes were added just to ensure that they characters are handled properly. It doesn't relate directly to the change from http_build_query() to drupal_http_build_query().
Comment #24
fabianx commentedRTBM - let’s get #2 in.
I agree that we expand the test scope here for the sole reason to see that the new function does not Regress something with quotes.
Test hardening.
Comment #26
mcdruid commentedThank you contributors!