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.

CommentFileSizeAuthor
boost-wrokng-strpos-function-usage.patch519 bytesSpleshka
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

berdyshev’s picture

Status: Needs review » Needs work

I think it should be

if (strpos($url, $base_root) === FALSE) {

because strpos() function returns FALSE if there is no occurrence found. And you use === which means the comparison by value and type.

Spleshka’s picture

Status: Needs work » Needs review

Sorry, 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.

berdyshev’s picture

Status: Needs review » Reviewed & tested by the community

Oh, sorry, misunderstanding.

Spleshka’s picture

Any updates here? Patch seems to be obvious.

bgm’s picture

Assigned: Unassigned » bgm
Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Committed to 7.x-1.x. Thanks for the patch, and apologies for the delay.

Spleshka’s picture

Thanks for the commiting this!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.