From b5ec13fa896fc9d3e10f46e1d1106d77c6f9cc90 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Nov 2010 20:12:19 +0300 Subject: [PATCH] make sure cleanup_tags() actually cleans stuff up --- functions.php | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/functions.php b/functions.php index 2331c89f..ed781586 100644 --- a/functions.php +++ b/functions.php @@ -7149,14 +7149,40 @@ $interval_query = "date_updated < DATE_SUB(NOW(), INTERVAL $days DAY)"; } - $query = "SELECT ttrss_tags.id AS id - FROM ttrss_tags, ttrss_user_entries, ttrss_entries - WHERE post_int_id = int_id AND $interval_query AND - ref_id = ttrss_entries.id AND tag_cache != '' LIMIT $limit"; + $tags_deleted = 0; - $result = db_query($link, $query); + while ($limit > 0) { + $limit_part = 500; + + $query = "SELECT ttrss_tags.id AS id + FROM ttrss_tags, ttrss_user_entries, ttrss_entries + WHERE post_int_id = int_id AND $interval_query AND + ref_id = ttrss_entries.id AND tag_cache != '' LIMIT $limit_part"; + + $result = db_query($link, $query); + + $ids = array(); + + while ($line = db_fetch_assoc($result)) { + array_push($ids, $line['id']); + } + + if (count($ids) > 0) { + $ids = join(",", $ids); + print "."; + + $tmp_result = db_query($link, "DELETE FROM ttrss_tags WHERE id IN ($ids)"); + $tags_deleted += db_affected_rows($link, $tmp_result); + } else { + break; + } + + $limit -= $limit_part; + } + + print "\n"; - return db_affected_rows($link, $result); + return $tags_deleted; } ?> -- 2.39.5