From 5e6e9fcc56529b155c7f1e1f057eed8a4aaaf406 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 11 Feb 2018 05:47:50 -0800 Subject: [PATCH] When purging drafts after a transaction edit, purge all drafts Summary: Fixes T13071. See that task for discusison. I think this `<= version` constraint is needless in normal cases (it should match everything in the table anyway), and slightly harmful in bizarre cases where a draft somehow gets a much larger ID than it should have. Test Plan: - Gave a draft an unreasonably large ID. - Pre-patch, observed: submitting comments on the draft's object does not clear the draft. - Post-patch: submitting comments on the draft's object now clears the draft correctly. - Also added comments/actions, reloaded pages, saw drafts stick properly. Maniphest Tasks: T13071 Differential Revision: https://secure.phabricator.com/D19060 --- .../draft/storage/PhabricatorVersionedDraft.php | 9 +++------ .../transactions/editengine/PhabricatorEditEngine.php | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/applications/draft/storage/PhabricatorVersionedDraft.php b/src/applications/draft/storage/PhabricatorVersionedDraft.php index 0daf13e8c5..58cdb67599 100644 --- a/src/applications/draft/storage/PhabricatorVersionedDraft.php +++ b/src/applications/draft/storage/PhabricatorVersionedDraft.php @@ -80,20 +80,17 @@ final class PhabricatorVersionedDraft extends PhabricatorDraftDAO { public static function purgeDrafts( $object_phid, - $viewer_phid, - $version) { + $viewer_phid) { $draft = new PhabricatorVersionedDraft(); $conn_w = $draft->establishConnection('w'); queryfx( $conn_w, - 'DELETE FROM %T WHERE objectPHID = %s AND authorPHID = %s - AND version <= %d', + 'DELETE FROM %T WHERE objectPHID = %s AND authorPHID = %s', $draft->getTableName(), $object_phid, - $viewer_phid, - $version); + $viewer_phid); } } diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php index ea3b987568..ea171a421c 100644 --- a/src/applications/transactions/editengine/PhabricatorEditEngine.php +++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php @@ -1985,8 +1985,7 @@ abstract class PhabricatorEditEngine if (!$is_preview) { PhabricatorVersionedDraft::purgeDrafts( $object->getPHID(), - $viewer->getPHID(), - $this->loadDraftVersion($object)); + $viewer->getPHID()); $draft_engine = $this->newDraftEngine($object); if ($draft_engine) {