aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2023-04-14 09:21:33 +0200
committerMario Vavti <mario@mariovavti.com>2023-04-14 09:21:33 +0200
commitd8811b499d5aa2559ec13862a27f70404206e0c5 (patch)
tree5dd68237e02554aa094462fb026fc366ca607799 /include/items.php
parent20f4538db4fdfe74c060670caf46a754f856313e (diff)
downloadvolse-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.php55
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) {