From 9fac43a3a3f1993e4ffaa543da6a6b3e175fc7f4 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 1 Nov 2019 10:34:02 +0100 Subject: Better photo cache expiry processing --- Zotlabs/Daemon/Cron.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index a08d2b7d2..94d2b634f 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -97,13 +97,14 @@ class Cron { // Clean expired photos from cache - $age = get_config('system','active_expire_days', '30'); - $r = q("SELECT DISTINCT xchan, content FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s", - intval(PHOTO_CACHE), - db_utcnow(), - db_quoteinterval($age . ' DAY') + $sql_interval = db_utcnow() . ' - ' . db_quoteinterval(get_config('system','active_expire_days', '30') . ' DAY'); + $r = q("SELECT DISTINCT xchan, content FROM photo WHERE photo_usage = %d AND expires < $sql_interval", + intval(PHOTO_CACHE) ); if($r) { + q("DELETE FROM photo WHERE photo_usage = %d AND expires < $sql_interval", + intval(PHOTO_CACHE) + ); foreach($r as $rr) { $file = dbunescbin($rr['content']); if(is_file($file)) { @@ -113,11 +114,6 @@ class Cron { } } } - q("DELETE FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s", - intval(PHOTO_CACHE), - db_utcnow(), - db_quoteinterval($age . ' DAY') - ); // publish any applicable items that were set to be published in the future // (time travel posts). Restrict to items that have come of age in the last -- cgit v1.2.3