diff options
author | Mario Vavti <mario@mariovavti.com> | 2023-04-14 09:21:33 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2023-04-14 09:21:33 +0200 |
commit | d8811b499d5aa2559ec13862a27f70404206e0c5 (patch) | |
tree | 5dd68237e02554aa094462fb026fc366ca607799 /include/items.php | |
parent | 20f4538db4fdfe74c060670caf46a754f856313e (diff) | |
download | volse-hubzilla-d8811b499d5aa2559ec13862a27f70404206e0c5.tar.gz volse-hubzilla-d8811b499d5aa2559ec13862a27f70404206e0c5.tar.bz2 volse-hubzilla-d8811b499d5aa2559ec13862a27f70404206e0c5.zip |
improved item_expire()
Diffstat (limited to 'include/items.php')
-rw-r--r-- | include/items.php | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/include/items.php b/include/items.php index a9930470c..989edf683 100644 --- a/include/items.php +++ b/include/items.php @@ -3755,45 +3755,34 @@ function item_expire($uid,$days,$comment_days = 7) { $sql_extra = ((intval($expire_network_only)) ? " AND item_wall = 0 " : ""); - $expire_limit = get_config('system','expire_limit'); - if(! intval($expire_limit)) - $expire_limit = 5000; + $expire_limit = get_config('system','expire_limit', 1000); $item_normal = item_normal(); - $r = q("SELECT id FROM item - WHERE uid = %d - AND created < %s - INTERVAL %s - AND commented < %s - INTERVAL %s - AND item_retained = 0 - AND item_thread_top = 1 - AND resource_type = '' - AND item_starred = 0 - $sql_extra $item_normal LIMIT $expire_limit ", - intval($uid), - db_utcnow(), - db_quoteinterval(intval($days) . ' DAY'), - db_utcnow(), - db_quoteinterval(intval($comment_days) . ' DAY') - ); - - if(! $r) - return; - - $r = fetch_post_tags($r,true); - - foreach($r as $item) { - - // don't expire filed items + do { + $r = q("SELECT id FROM item + WHERE uid = %d + AND created < %s - INTERVAL %s + AND commented < %s - INTERVAL %s + AND item_retained = 0 + AND item_thread_top = 1 + AND resource_type = '' + AND item_starred = 0 + $sql_extra $item_normal LIMIT $expire_limit", + intval($uid), + db_utcnow(), + db_quoteinterval(intval($days) . ' DAY'), + db_utcnow(), + db_quoteinterval(intval($comment_days) . ' DAY') + ); - if (isset($item['term']) && get_terms_oftype($item['term'], TERM_FILE)) { - retain_item($item['id']); - continue; + if ($r) { + foreach ($r as $item) { + drop_item($item['id'], false); + } } - drop_item($item['id'],false); - } - + } while ($r); } function retain_item($id) { |