@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+8 -6
+8 -6
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 1300 1300 1301 1301 // TODO: Once everything is on EditEngine, just use getIsNewObject() to 1302 1302 // figure this out instead. 1303 - $mark_as_create = false; 1304 - $create_type = PhabricatorTransactions::TYPE_CREATE; 1305 - foreach ($xactions as $xaction) { 1306 - if ($xaction->getTransactionType() == $create_type) { 1307 - $mark_as_create = true; 1308 - break; 1303 + $mark_as_create = $is_new; 1304 + if (!$mark_as_create) { 1305 + $create_type = PhabricatorTransactions::TYPE_CREATE; 1306 + foreach ($xactions as $xaction) { 1307 + if ($xaction->getTransactionType() == $create_type) { 1308 + $mark_as_create = true; 1309 + break; 1310 + } 1309 1311 } 1310 1312 } 1311 1313