<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.
#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.
Yeah, 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.
Comments
Comment #2
twistor commentedComment #3
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 commentedComment #7
twistor 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 commentedComment #9
fabianx 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 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.