Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
With PHP 5.3.2, bogus strings like 'http:///' throw an E_WARNING exception from parse_url() - this was fixed in 5.3.3. For the sake of those working in environments with older versions of PHP, suppressing the warnings would be helpful.
Comment | File | Size | Author |
---|---|---|---|
pathologic-suppress_parse_url_warnings.patch | 2.79 KB | mikeryan | |
Comments
Comment #1
Garrett Albright CreditAttribution: Garrett Albright commentedDespite the thrown warning, does the function behave correctly otherwise (returning FALSE with an illegit string)? I don't have easy access to 5.3.2 to test with.
Comment #2
mikeryanSorry for the slow response - yes, it does return FALSE, and things proceed cleanly from that point.
Thanks.
Comment #3
Garrett Albright CreditAttribution: Garrett Albright commentedThank you. I think I'd rather implement a wrapper around parse_url() which uses try/catch instead of using the hacky @ operator, as your patch does. But that should be an easy fix. Fortunately, it appears that D8 will require at least PHP 5.3.5, so I'll only need to implement this workaround in the D7 branch.
Comment #4
Garrett Albright CreditAttribution: Garrett Albright commentedComment #5
Garrett Albright CreditAttribution: Garrett Albright commentedDerp, that won't work - a warning is not an exception, and can't be "caught" that way.
Okay, I made a commit that uses @ before all parse_url() calls (along with a comment stating I do not wish to be judged by it :P ). Could you have a look when the next development release is available and let me know if it works for you?
Comment #6
treksler CreditAttribution: treksler commentedI am judging you by it :P
If anything, suppress errors on less than 5.3.3 explicitly via a small utility function
eg.
Comment #7
Garrett Albright CreditAttribution: Garrett Albright commentedI'm pretty far from convinced that that method is better than what we've got now…