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.
Comment | File | Size | Author |
---|---|---|---|
#5 | drupal-n2663752-5.patch | 555 bytes | DamienMcKenna |
Comments
Comment #2
twistor CreditAttribution: twistor as a volunteer commentedComment #3
ParisLiakos CreditAttribution: ParisLiakos commentedmakes sense, yes. essentially backporting #2531042: Undefined string index 0 in WebTestBase::getAbsoluteUrl() in PHP 7
Comment #4
DamienMcKennaThis should be rewritten to check if(empty($path)) rather than if($path === ''), which is what the patch from #2531042: Undefined string index 0 in WebTestBase::getAbsoluteUrl() in PHP 7 does.
Comment #5
DamienMcKennaUpdated to match #2531042.
Comment #6
Crell CreditAttribution: Crell at Platform.sh commentedComment #7
twistor CreditAttribution: twistor as a volunteer commented<rant>
I would argue the 8.x code is wrong.
empty()
should never be used on strings since'0'
is considered empty. In this case, it works, but only by sheer luck.We know that $path is both set, and a string, from the surrounding code. There's no need for NULL/FALSE checking. Explicit is better than implicit.
</rant>
I don't want to change this to NW because it's the way 8.x does it, and it works. Just a pet peeve of mine.
Comment #8
stefan.r CreditAttribution: stefan.r commentedComment #9
Fabianx CreditAttribution: Fabianx as a volunteer commented#7: You are 100% right. Can you open a follow-up issue to fix it in both versions?
Unfortunately we should use the same code as in 8.x - even if its wrong. However we might be able to get the fix into 8.x - really quickly - as core moves pretty fast these times.
Comment #10
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedYeah, I agree, in theory empty() is wrong here but we use it in so many places already where it's technically incorrect (plus Drupal 8 did it this way too) that it is best to leave that to a separate issue.
Committed to 7.x - thanks!
I also credited all the people from #2531042: Undefined string index 0 in WebTestBase::getAbsoluteUrl() in PHP 7 in the commit message here.