If I have "purge expired cache files on cron runs" set to active and there are no files in the cache directory, because there were no anonymos user browsing my site, I get an error in _boost_rmdir_rf because of the foreach which gets an empty array and therefore produces an error.

The solution was to wrap the foreach in an additional if-statement.

The patch is attached.

CommentFileSizeAuthor
#2 boost-356613.patch1.42 KBmikeytown2
boost_rmdir_rf.patch412 bytesSteffenMaass

Comments

mikeytown2’s picture

Component: Code » Expiration logic

These 2 are duplicates
#433534: Invalid argument for foreach() in /var/www/vhosts/azbigmedia.com/httpdocs/sites/all/modules/boost/boost.module on line 649.
#373444: Invalid argument supplied for foreach(): _boost_rmdir_rf()

Wondering if this would be a better way to do it

  $files = glob($dirname . '/*', GLOB_NOSORT);
  if (!$files) {
    $files = array();
  }
  foreach ($files as $file) {

http://www.php.net/glob
http://www.php.net/foreach

mikeytown2’s picture

StatusFileSize
new1.42 KB
mikeytown2’s picture

Going with the format of the original patch for performance reasons.

mikeytown2’s picture

Assigned: Unassigned » mikeytown2
Priority: Normal » Critical

This needs to go in before I can do an alpha 3 release. This error will be appearing a lot more now that symlinks are no longer being used. Speaking of that... Note: The site owner needs to ftp in and clear the cache dir, since it should be free of symlinks when upgrading to this newer boost version.

rsvelko’s picture

in the release notes as an update notice we should write that cache must be cleared manually - would you do that mikey ?

rsvelko’s picture

Status: Needs review » Reviewed & tested by the community

reviewed the old and the new functions letter by letter - all ok .

I tried to test this - to make the error happen before the patch and ensure that it is gone after that - but somehow did not succeed in that.

Nevermind - the patch is trivial and keeps us safe - so RTBC. no risk here.

the old logic is preserved - we only wrapped the foreach in an if .

mikeytown2’s picture

patch applied

mikeytown2’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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