From 17218b0b0883ee105622f8431d8857c8d02d4060 Mon Sep 17 00:00:00 2001
From: Shish <shish@shishnet.org>
Date: Wed, 3 Feb 2010 23:54:43 +0000
Subject: [PATCH] correct some seemingly innocent behaviour, and thus fix a
 corner case in another extension

---
 ext/image/main.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ext/image/main.php b/ext/image/main.php
index 4be448a6..e6cc87dd 100644
--- a/ext/image/main.php
+++ b/ext/image/main.php
@@ -246,7 +246,14 @@ class ImageIO extends SimpleExtension {
 
 		log_info("image", "Uploaded Image #{$image->id} ({$image->hash})");
 
-		send_event(new TagSetEvent($image, $image->get_tag_array()));
+		# at this point in time, the image's tags haven't really been set,
+		# and so, having $image->tag_array set to something is a lie (but
+		# a useful one, as we want to know what the tags are /supposed/ to
+		# be). Here we correct the lie, by first nullifying the wrong tags
+		# then using the standard mechanism to set them properly.
+		$tags_to_set = $image->get_tag_array();
+		$image->tag_array = array();
+		send_event(new TagSetEvent($image, $tags_to_set));
 	}
 // }}}
 // fetch image {{{