Invalid argument for foreach on boost.module line 513

setvik - June 4, 2009 - 06:45
Project:Boost
Version:6.x-1.0-beta1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

In boost_cache_expire_derivative(), the following code:

  #path redirects
  if (module_exists('path_redirect')){
    $path_redirects = boost_path_redirect_load(array('redirect' => $path));
  }

  #flush caches
  boost_cache_expire($path_alias, $wildcard);
  foreach($path_redirects as $path_redirect) {
    boost_cache_expire($path_redirect['path'], $wildcard );
  }

Results in "warning: Invalid argument supplied for foreach() in /www/beta4/httpdocs/sites/all/modules/boost/boost.module on line 513"

if the path_redirect module is not installed.

To fix, initialize $path_redirects to an empty array or wrap the foreach in an "if (isset(..."

See patch for latter solution.

AttachmentSize
boost.invalidargument.patch551 bytes

#1

mikeytown2 - June 4, 2009 - 06:54
Status:active» reviewed & tested by the community

Tested & looks good. Thanks for supplying the patch!

#2

mikeytown2 - June 4, 2009 - 08:43
Status:reviewed & tested by the community» fixed

committed

#3

asb - June 15, 2009 - 17:20

Hi,

confirming the issue in Drupal 6.12 with 6.x-1.0-beta1. The patch applies cleanly and works as advertised.

Thanks & greetings, -asb

#4

System Message - June 29, 2009 - 17:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.