function print_pdf_cache_clean in Printer, email and PDF versions 7.2
Removes pdf files for nodes/paths if they are older than the lifetime.
1 call to print_pdf_cache_clean()
- print_pdf_cron in print_pdf/
print_pdf.module - Implements hook_cron().
File
- print_pdf/
print_pdf.module, line 367 - Displays Printer-friendly versions of Drupal pages.
Code
function print_pdf_cache_clean() {
$lifetime = variable_get('print_pdf_cache_lifetime', PRINT_PDF_CACHE_LIFETIME_DEFAULT);
if ($lifetime > 0) {
$files = file_scan_directory(print_pdf_cache_dir(), '!\\d+\\.pdf$!');
foreach ($files as $file) {
// For all files in the cache directory, see when they were last accessed.
$result = db_query("SELECT timestamp FROM {print_pdf_page_counter} WHERE path = :path", array(
':path' => 'node/' . $file->name,
))
->fetchField();
// Keep the file only if last access was within the cache max life value.
if ($result === FALSE || $result + $lifetime < REQUEST_TIME) {
print_pdf_cache_delete($file->name);
}
}
}
}