Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
locale.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
28 Dec 2012 at 15:03 UTC
Updated:
29 Jul 2014 at 21:42 UTC
Jump to comment: Most recent file
Comments
Comment #1
sutharsan commentedConverting the drupal_http_request to Guzzle. The patch removes the functionality to detect a redirect and store the resulting uri. This code came from the original l10n_update module, but no other core implementation of drupal_http_redirect does this and Guzzle (as it is used here) does not return any header information when a 301 occurs.
Comment #2
berdirThere seems to be a getLocation() method on the Response object, does this return that information?
This feature has been removed in the aggregator implementation, but I actually think that this is incorrect, as I've written in #1447736-187: Adopt Guzzle library to replace drupal_http_request().
Comment #3
sutharsan commentedI've tried both getLocation() and getRawHeaders() and both return not data (NULL and not the expected header info). I've tested with two kinds of 301 redirects: a redirecting drupal URL (Redirect module on a D7 site) and a "Redirect 301 ..." in .htaccess. The getStatusCode() method returns 200 in all cases. So I think I have found a bug in Guzzle (implementation). I will investigate further.
Comment #4
berdirAh right. Because the final response *is* a 200 OK and has no Location header, obviously.
I think that's what getPreviousResponse() is for, you could call that and check if it is a redirect/has a Location.
Comment #5
sutharsan commentedThanks, I found
getPreviousResponsetoo.Comment #6
sutharsan commentedA slightly more selective one, only store the final url on 301.
Comment #7
yesct commented#6: locale-guzzle-1875614-6.patch queued for re-testing.
Comment #8
sutharsan commentedWith the new CurlException the exception handling van be better grouped. Although not essentially different form the previous patch, I think the code is more clear this way. It uses three catch methods:
Comment #9
sutharsan commentedEhm, CurlException is not new. It was only the error message that was in improved in the latest release.
Comment #10
berdirCurlException is a childclass of RequestException, so you don't need the CurlException block unless you actually want to do something different with it.
Otherwise, this is a nice example of when you actually have a case for handling those exceptions differently.
Comment #11
sutharsan commented@berdir, unfortunately I don't have a case to handle curl exceptions differently ;)
Removed the CurlException handling.
Comment #13
berdirShould have a use for RequestException instead now.
Comment #14
sutharsan commentedDone.
Comment #15
berdirThis should now use Drupal::httpClient().
Comment #16
yesct commentedlooks like the true false lines are inaccurate now.
(also missing newline before @return)
I tried to address #15
and looked at the sample code in other guzzle conversions and the change notice:
http://drupal.org/node/1862446
But I'm still not sure.
Also, I didn't know if, like the change notice sample, if the setup should happen before the try {} and then in the try, do the ->send.
Comment #18
berdirget() was a method on the drupal_container(), this just needs Drupal::httpClient()->head()->send().
Comment #19
berdirThis should work.
Comment #20
sutharsan commentedWhy a string concatenation like this? It fails in rtl languages. Also the content returned by
getReasonPhrase()may not be safe as it can contain the response message body. SeeResponse->getMessage().Comment #21
berdirThat's how we did in all other places where we logged the reason. It's an untranslated string anyway (e.g. "403 Access Denied") so LTR/RTL shouldn't really matter?
I don't see how getReasonPhrase could contain the body? getMessage() doesn't do anything with the reason phrase and if you look at getRawHeaders(), it's done in a very similar way there.
Comment #22
ParisLiakos commentedwhy are we removing those from docblock? i see the behavior is the same after the patch
maybe add: and the file location if a redirect occurs
Comment #23
sutharsan commented@berdir, I agree that the reason phrase is a hardcoded status text and not message body text. I can't reproduce how I got to 'getMessage' but it is indeed not called and not related.
For RTL languages it does matter. With this concatenation we place the reason phrase in front of the "HTTP request to @url ..." sentence, and not behind as in LTR languages. It is hard coded, it can not be changed. When using t() the order can be changed by the translator, that is the whole difference. Alternatively we can contatenate the strings with a
<br />.Comment #24
berdirSorry but I still don't get what you mean.
The status code and reason phrase *is* a t() argument that is injected into a placeholder.
So a RTL language would display it as "403 Access denied rorre htiw deliaf lru@ ot tseuqer PTTH" (Yes, I actually reversed the english string ;)), if the placeholder is on the left side. So the only thing we could do is split it up and have to placeholders as @errorcode @errormessage so that they could reverse that too. But given that were talking about a string that is very likely in English, I'm not sure that makes sense? If you think it does, feel free to change :)
Comment #25
sutharsan commentedOops, now I see. Yes it is a t() argument. Sorry for the confusion, I must have been away from core development too long ;)
Comment #26
berdir@Sutharsan: Great, can you explain what's the deal with those @return documentation changes pointed out in #22? Once that's updated then we can get this in, this is one of two remaining conversion issues now and the last that's not RTBC :)
Comment #27
sutharsan commentedComment changed as suggested by rootatwc.
Comment #28
ParisLiakos commentedlooks good to go now, thanks:)
Comment #29
webchickAll right, let's get these out of the way so we can close a major!
Committed and pushed to 8.x. Thanks!