From cbe5f27eb611a218cd59a5b01de335ad15db63c3 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 29 Jan 2014 21:37:51 +0000 Subject: [PATCH] in-place tag renaming when possible, rather than mass editing thousands of images --- ext/tag_edit/main.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index f5ae0ad2..0f1655a1 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -189,6 +189,18 @@ class TagEdit extends Extension { log_info("tag_edit", "Mass editing tags: '$search' -> '$replace'"); + if(count($search_set) == 1 && count($replace_set) == 1) { + $images = Image::find_images(0, 10, $replace_set); + if(count($images) == 0) { + log_info("tag_edit", "No images found with target tag, doing in-place rename"); + $database->execute("DELETE FROM tags WHERE tag=:replace", + array("replace" => $replace_set[0])); + $database->execute("UPDATE tags SET tag=:replace WHERE tag=:search", + array("replace" => $replace_set[0], "search" => $search_set[0])); + return; + } + } + $last_id = -1; while(true) { // make sure we don't look at the same images twice.