From 23697dd525c557fb42d99c4338a694febee8bcd3 Mon Sep 17 00:00:00 2001 From: Parziphal Date: Thu, 20 Feb 2014 16:48:24 -0500 Subject: [PATCH] Changed purge_tags(). Tag purging was done directly to the database, leaving the tags' history entries orphan. --- app/models/Tag.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/Tag.php b/app/models/Tag.php index e586a3e..aefe85b 100755 --- a/app/models/Tag.php +++ b/app/models/Tag.php @@ -550,11 +550,11 @@ class Tag extends Rails\ActiveRecord\Base static public function purge_tags() { - $sql = - "DELETE FROM tags " . - "WHERE post_count = 0 AND " . + $condition = "post_count = 0 AND " . "id NOT IN (SELECT alias_id FROM tag_aliases UNION SELECT predicate_id FROM tag_implications UNION SELECT consequent_id FROM tag_implications)"; - self::connection()->executeSql($sql); + foreach(Tag::where($condition)->take() as $tag) { + $tag->destroy(); + } } static public function recalculate_post_count()