Index: trunk/ippTools/share/pubtool_definerun.sql
===================================================================
--- trunk/ippTools/share/pubtool_definerun.sql	(revision 28372)
+++ trunk/ippTools/share/pubtool_definerun.sql	(revision 28411)
@@ -38,4 +38,24 @@
         AND (camRun.magicked != 0 OR publishClient.magicked = 0)
     -- WHERE hook %s
+    UNION
+    -- Get diffphots to publish
+    SELECT DISTINCT
+        client_id,
+        diff_phot_id AS stage_id,
+        diffPhotRun.label AS src_label
+    FROM publishClient
+    JOIN diffPhotRun
+    JOIN diffRun USING(diff_id)
+    JOIN diffInputSkyfile USING(diff_id)
+    JOIN warpRun ON warpRun.warp_id = diffInputSkyfile.warp1 -- Only JOINing input, not reference!
+    JOIN fakeRun USING(fake_id)
+    JOIN camRun USING(cam_id)
+    JOIN chipRun USING(chip_id)
+    JOIN rawExp USING(exp_id)
+    WHERE publishClient.stage = 'diffphot'
+        AND publishClient.active = 1
+        AND diffPhotRun.state IN ('full', 'cleaned', 'goto_cleaned')
+        AND (diffRun.diff_mode = 4 OR publishClient.magicked = 0) -- diffPhotRun doesn't respect magic
+    -- WHERE hook %s
     ) AS publishToDo
 -- Only get stuff that hasn't been published
