Changed purge_tags().

Tag purging was done directly to the database, leaving the tags' history entries orphan.
This commit is contained in:
Parziphal 2014-02-20 16:48:24 -05:00
parent 28269e00c6
commit 23697dd525

View File

@ -550,11 +550,11 @@ class Tag extends Rails\ActiveRecord\Base
static public function purge_tags() static public function purge_tags()
{ {
$sql = $condition = "post_count = 0 AND " .
"DELETE FROM tags " .
"WHERE 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)"; "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() static public function recalculate_post_count()