Problem/Motivation
Drupal determines whether it is serving an HTTPS request (which is not a completely trivial check) right after including the settings.php
file. However that logic can be also useful while initializing settings, for instance when crafting base URLs. Currently that logic has to be copied wherever it's needed.
In Drupal 8 we have Symfony\Component\HttpFoundation\Request::isSecure()
so this applies only to Drupal 7.
Proposed resolution
Factor out logic to detect HTTPS requests into a drupal_is_https()
API function.
Remaining tasks
- Validate the suggested solution
Write a patch- Reviews
User interface changes
None
API changes
None, only additions.
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#2 | drupal-is_https-2821203-2.patch | 991 bytes | plach |
Comments
Comment #2
plachComment #3
marco CreditAttribution: marco at Tag1 Consulting commentedReviewed and tested, works as expected and I'd love if this gets merged.
Comment #4
stefan.r CreditAttribution: stefan.r commentedThis seems useful, just wondering if this needs a comment "introduced in Drupal 7.52" or such (to communicate that calling this will break on older core installs), and if small API additions like this can go into a bugfix release or should wait until 7.60.
Comment #5
plachAdded change record at https://www.drupal.org/node/2824590.
Totally fine with this going into version 7.60: it's not a bug fix so I'd say it's actually the right thing to do. Instead I'm not sure about adding a note with the version the new function was introduced in: we already have the change record and we don't seem to do that anywhere else.
Comment #6
Fabianx CreditAttribution: Fabianx as a volunteer commentedMarking for commit. I am not yet sure this is a 7.60 target, but marking as such for now.
I think we need to talk about this internally.
Comment #7
stefan.r CreditAttribution: stefan.r commentedSince this is a very minor addition, 7.60 is a bit away still, and we have a change record for it anyway, let's just add it to the next bugfix release.
Comment #9
stefan.r CreditAttribution: stefan.r commentedComment #10
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedI went ahead and published the change record with minor edits.