From ec7a82e58a5512b572753bfb24781b4c70a9807f Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Fri, 27 Feb 2026 21:15:10 +0100 Subject: [PATCH] Transaction Editor: fix "is create" recognizer Summary: From time to time we discover that things using editors (PhabricatorApplicationTransactionEditor) have transactions not marked as "is create". As workaround, we use to manually call this method on every specific transaction: PhabricatorApplicationTransaction#setIsCreateTransaction(true); After this change, manually setting "is create" on every transaction is no longer necessary, since transactions should be marked as "is create" by simply checking the entity ID. We can then remove similar unnecessary extra workarounds in Phorge core, and Phorge extensions. Like this, it's not needed anymore: aad704d0fce53225f91f36c8133dbeb2d6199a0d Incidentally, the "is create" check is now faster during object creations, since there is no need to always traverse the array of transactions anymore to know that. Closes T16086 Closes T16222 Closes T16085 Closes T16223 Ref T16220 Test Plan: From the UX, before and after the change: - create a task: you still see "created this task" in the feed - update the task again changing title and description: it still works, you see "renamed" and "updated the task description" - create a repository and visit its history: you still see "created this object" - edit the name of the same repository: you still see "renamed this repository" - create a paste: you still see "created this paste" - rename that paste: you still see "changed the title of this paste" - create a project: you still see "created this project" - rename that project: you still see "renamed this project" - create a calendar event: you still see "created this event" - rename that calendar event: you still see "renamed this event" - create a wiki document: you still see "created this document" - rename that wiki document: you still see "changed the title from" Run this broken API call to test T16223, before and after the patch: echo '{ "title":"Created from API maniphest.createtask", "description":"description", "priority":"50", "viewPolicy":"obj.maniphest.author", "editPolicy":"obj.maniphest.author" }' | arc call-conduit --conduit-uri http://phorge.localhost maniphest.createtask -- After this patch, you finally see the feed about the custom policy = "Author", so it's more consistent with the frontend. ---- Create a simple task using the recent API: echo '{"transactions":[ {"type": "title", "value": "Created from API maniphest.edit"}, {"type": "description", "value": "description"} ]}' | arc call-conduit --conduit-uri http://phorge.localhost maniphest.edit -- Still works, still successfully marked as "created" in the feed. No regressions. Manually update it, no regressions. ---- Create a more complicated task with custom policies using the recent API: echo '{"transactions":[ {"type": "title", "value": "Created from API maniphest.edit with policies"}, {"type": "description", "value": "description"}, {"type": "priority", "value": "normal"}, {"type": "view", "value": "obj.maniphest.author"}, {"type": "edit", "value": "obj.maniphest.author"} ]}' | arc call-conduit --conduit-uri http://phorge.localhost maniphest.edit -- Still works, still successfully marked as "created" in the feed. Still info about the initial policies. No regressions. Manually update it, no regressions. ---- Run all unit tests: arc unit --everything All green (but another unrelated about remarkup - T15973) Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: aklapper, avivey, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T16220, T16222, T16086, T16085, T16223 Differential Revision: https://we.phorge.it/D26272 --- .../PhabricatorApplicationTransactionEditor.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index a80b06839a..904b004898 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -1300,12 +1300,14 @@ abstract class PhabricatorApplicationTransactionEditor // TODO: Once everything is on EditEngine, just use getIsNewObject() to // figure this out instead. - $mark_as_create = false; - $create_type = PhabricatorTransactions::TYPE_CREATE; - foreach ($xactions as $xaction) { - if ($xaction->getTransactionType() == $create_type) { - $mark_as_create = true; - break; + $mark_as_create = $is_new; + if (!$mark_as_create) { + $create_type = PhabricatorTransactions::TYPE_CREATE; + foreach ($xactions as $xaction) { + if ($xaction->getTransactionType() == $create_type) { + $mark_as_create = true; + break; + } } } -- 2.51.2