/**
* Prunes images from the file system cache that have expired
*
* @param integer|null $pruneDate
*/
public function pruneImageCache($pruneDate = null)
{
$db = $this->_getDb();
if ($pruneDate === null)
{
if (!XenForo_Application::getOptions()->imageCacheTTL)
{
return;
}
$pruneDate = XenForo_Application::$time - (86400 * XenForo_Application::getOptions()->imageCacheTTL);
}
$images = $this->fetchAllKeyed('
SELECT *
FROM xf_image_proxy
WHERE fetch_date < ?
AND pruned = 0
LIMIT 0, 5000
', 'image_id', $pruneDate);
if ($images)
{
foreach ($images AS $imageId => $image)
{
$this->_deleteFile($image);
}
$db->update('xf_image_proxy', array(
'pruned' => 1
), 'image_id IN (' . $db->quote(array_keys($images)) . ')');
}
}