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.
Hi,
While testing second branch of Cache Expiration I found small bug in usage of strpos() function. See your code (line 382):
if (strpos($base_root, $url) == 0) {
There are two bugs:
- First params should be $url (it's haystack) and the second should be $base_root (it's needle here).
- Your should use === instead of ==. If you use == even if strpos() returns FALSE the condition will be passed successfully.
Patch that fixes this attached.
Comment | File | Size | Author |
---|---|---|---|
boost-wrokng-strpos-function-usage.patch | 519 bytes | Spleshka | |
Comments
Comment #1
berdyshev CreditAttribution: berdyshev commentedI think it should be
because strpos() function returns FALSE if there is no occurrence found. And you use === which means the comparison by value and type.
Comment #2
SpleshkaSorry, but you are wrong. We need strpos() to return 0, not FALSE. It means that $base_root was found in $url starting with the first letter. In other cases condition should fail.
Comment #3
berdyshev CreditAttribution: berdyshev commentedOh, sorry, misunderstanding.
Comment #4
SpleshkaAny updates here? Patch seems to be obvious.
Comment #5
bgm CreditAttribution: bgm commentedCommitted to 7.x-1.x. Thanks for the patch, and apologies for the delay.
Comment #6
SpleshkaThanks for the commiting this!