From b0dab3efa3cc0a1cf7621bd60e1383b6f96c706e Mon Sep 17 00:00:00 2001 From: Casey Peel Date: Tue, 18 Aug 2026 09:19:23 -0700 Subject: [PATCH] Update timestamp on duplicate format preview event keys If, for whatever reason, the destination project already has format preview events for the source page/round/user, just update the timestamp from the source instead of raising a duplicate key error. --- pinc/FormatPreview.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pinc/FormatPreview.inc b/pinc/FormatPreview.inc index db1965ada..bc804b413 100644 --- a/pinc/FormatPreview.inc +++ b/pinc/FormatPreview.inc @@ -62,9 +62,12 @@ class FormatPreview " INSERT INTO format_preview_events (projectid, image, round_id, username, timestamp) - SELECT '%s', image, round_id, username, timestamp - FROM format_preview_events - WHERE projectid = '%s' $images_where + SELECT * FROM ( + SELECT '%s', image, round_id, username, timestamp + FROM format_preview_events + WHERE projectid = '%s' $images_where) AS new + ON DUPLICATE KEY UPDATE + timestamp = new.timestamp ", DPDatabase::escape($dest_projectid), DPDatabase::escape($src_projectid)