Closed (duplicate)
Project:
ImageCache
Version:
6.x-2.0-beta12
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
26 Jan 2012 at 10:43 UTC
Updated:
3 Jun 2012 at 01:06 UTC
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.
| Comment | File | Size | Author |
|---|---|---|---|
| imagecache.diff | 1.22 KB | Romka |
Comments
Comment #1
fizk commentedDuplicate of #1243258: use lock.inc instead of a file lock.