In my project I had a problem with next code in _imagecache_cache function:

  $lockfile = file_directory_temp() .'/'. $preset['presetname'] . basename($src);
  if (file_exists($lockfile)) {
    watchdog('imagecache', 'ImageCache already generating: %dst, Lock file: %tmp.', array('%dst' => $dst, '%tmp' => $lockfile), WATCHDOG_NOTICE);
    // 307 Temporary Redirect, to myself. Lets hope the image is done next time around.
    header('Location: '. request_uri(), TRUE, 307);
    exit;
  }

In some unknown for me reason this lockfile was created for one of images, but didn't deleted then. And all users who requested this image were redirected infinitely.

I have added deleting of this lockfile after php max_execution_time timeout:

  $lockfile = file_directory_temp() .'/'. $preset['presetname'] . basename($src);
  if (file_exists($lockfile)) {
    if(time() - filemtime($lockfile) > ini_get('max_execution_time')) {
      watchdog('imagecache', 'ImageCache already generating: %dst, Lock file: %tmp.', array('%dst' => $dst, '%tmp' => $lockfile), WATCHDOG_NOTICE);
      // 307 Temporary Redirect, to myself. Lets hope the image is done next time around.
      header('Location: '. request_uri(), TRUE, 307);
      exit;
    } else {
      watchdog('imagecache', 'Abandoned lock file has been deleted: %tmp.', array('%tmp' => $lockfile), WATCHDOG_NOTICE);
      unlink($lockfile);
    }
  }

My patch is in attach.

CommentFileSizeAuthor
imagecache.diff1.22 KBRomka

Comments

fizk’s picture

Status: Needs review » Closed (duplicate)