1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

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
This commit is contained in:
epriestley 2018-02-11 05:47:50 -08:00
parent 653bc0fa01
commit 5e6e9fcc56
2 changed files with 4 additions and 8 deletions

View file

@ -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);
}
}

View file

@ -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) {