Index: trunk/ippTools/share/pubtool_definerun.sql
===================================================================
--- trunk/ippTools/share/pubtool_definerun.sql	(revision 31969)
+++ trunk/ippTools/share/pubtool_definerun.sql	(revision 32116)
@@ -20,8 +20,14 @@
     JOIN chipRun USING(chip_id)
     JOIN rawExp USING(exp_id)
+    LEFT JOIN magicDSRun ON magicDSRun.stage = 'diff' AND magicDSRun.stage_id = diff_id
     WHERE publishClient.stage = 'diff'
         AND publishClient.active = 1
         AND diffRun.state IN ('full', 'cleaned', 'goto_cleaned')
-        AND (diffRun.magicked != 0 OR diffRun.diff_mode = 4 OR publishClient.magicked = 0)
+        AND ( diffRun.diff_mode = 4
+           OR (publishClient.magicked AND diffRun.magicked != 0)
+           OR (publishClient.magicked = 0 AND 
+                (diffRun.magicked = 0 OR (diffRun.magicked != 0 AND magic_ds_id IS NOT NULL))
+              )
+           )
     -- WHERE hook %s
     UNION
