== Entities Exploration ==
Preliminary questions:
1. How does it work the `PhabricatorDestructibleInterface`?
2. How does a `destroyObjectPermanently(PhabricatorDestructionEngine $engine)` should work?
Exploration:
This interface
| Entity |Has Child-Entity? | Has `PhabricatorDestructibleInterface`? | What does it call? | and is it wrapped in transaction? |
|------------------|------------------| --------------------------------------|--|--|
| `ManiphestTask` | No? (fields) | Yes. Has `destroyObjectPermanently()` | ..that calls `$this->delete()` | โ
..inside `openTransaction()` |
| `PonderQuestion` | Yes | Yes. Has `destroyObjectPermanently()` | ..that calls `$engine->destroyObject(PonderAnswer)` and `$this->delete()` | โ
..inside `openTransaction()` |
| - `PonderAnswer` | No | Yes. Has `destroyObjectPermanently()` | ..that calls `$this->delete()` | โ
..inside `openTransaction()` |
| `PhabricatorDashboard` | No? | Yes. Has `destroyObjectPermanently()` | ..that calls `$this->delete()` | ๐
.. without `openTransaction()` |
| `PhabricatorDashboardPanel` | Yes? | Yes. Has `destroyObjectPermanently()` | ..that calls `$this->delete()` | โ
..inside `openTransaction()` |
| `PhameBlog` | Yes | Yes. Has `destroyObjectPermanently()` | ..that calls `$engine->destroyObject(PhamePost)` and `$this->delete()` | โ
..inside `openTransaction()` |
| - `PhamePost` | No (comments?) | Yes. Has `destroyObjectPermanently()` | ..that calls `$this->delete()` | โ
..inside `openTransaction()` |
|`PhrictionContent`| No (comments?) | Yes. Has `destroyObjectPermanently()` | ..that calls `$this->delete()` | ๐
.. without `openTransaction()` |
| `HeraldRule` | Yes (conditions?)| Yes. Has `destroyObjectPermanently()` | ..that calls `$this->delete()` | โ
..inside `openTransaction()` |
| - `HeraldCondition`| No | No. | | |
| -- `HeraldActionRecord`| No | No. | | |
| `HeraldTranscript` | Yes | Yes. Has `destroyObjectPermanently()` | ..that calls `$this->delete()` | โ
..inside `openTransaction()` |
| - `HeraldConditionTranscript`| Yes (results) | No. | | |
| -- `HeraldTranscriptResult` | No? | No. | | |
Notes:
- `*` = Has Child-Entities? If it has children-entities that cannot live alone without this parent.
-----
== Destruction Engines Exploration ==
Preliminary questions:
1. How does it work a `DestructionEngineExtension` (compared with the above?)
2. Who fires it?
Exploration:
Destruction Engines are engines that take "generic input objects" and destroy "related specific related entities".
For example, if you drop a Maniphest Task, its Herald Transcripts may be deleted thanks to the `HeraldTranscriptDestructionEngineExtension`.
These Destruction Engines are supposed to be executed in the background by `phd` after you destroy a generic object.
| Destruction Engine |What does it call? | and is it wrapped in transaction? |
|-----------------------------------------------------|-------------------------------------------------|--|
|`HeraldTranscriptDestructionEngineExtension` |calls `$engine->destroyObject(HeraldTranscript)` |๐
.. without `openTransaction()` |
|`PhabricatorPasswordDestructionEngineExtension` |calls `$engine->destroyObject(PhabricatorAuthPassword)`| ๐
.. without `openTransaction()` |
|`PhabricatorTokenDestructionEngineExtension` |calls `PhabricatorTokenGiven#delete()` |๐
.. without `openTransaction()` |
|`PhabricatorMailPropertiesDestructionEngineExtension`|calls `PhabricatorMetaMTAMailProperties#delete()`|๐
.. without `openTransaction()` |
|`PhabricatorWorkerDestructionEngineExtension` |calls `PhabricatorWorkerActiveTask#archiveTask()`|๐
.. without `openTransaction()` |
|`PhabricatorNotificationDestructionEngineExtension` |runs `DELETE` query |๐
.. without `openTransaction()` |
|`PhabricatorSearchIndexVersionDestructionEngineExtension`|runs `DELETE` query |๐
.. without `openTransaction()` |
|`PhabricatorSearchNgramsDestructionEngineExtension` |runs `DELETE` query |๐
.. without `openTransaction()` |
-----
Thanks for adding details.
-----
## Post Considerations
About {T15110}: how to destroy `PhabricatorFileAttachment` correctly?
From the perspective of its parent class `File`:
- `PhabricatorFile` has the child-entity `PhabricatorFileAttachment` that cannot live without a File
- โ so, it should probably act like `PonderQuestion` and `PhameBlog`
- โ so, it should probably call `$engine->destroyObject(PhabricatorFileAttachment)` and `$this->delete()` ..inside `openTransaction()`
- โ so `PhabricatorFileAttachment` should have a `PhabricatorDestructibleInterface`
- โ it can just behave like `PhamePost` and runs just `$this->delete()` ..inside `openTransaction()`
- it should exist a destruction engine to delete orphan `PhabricatorFileAttachment` - hypothetical `PhabricatorFileAttachmentDestructionEngineExtension`
- ๐ด๐ด๐ด๐ด โ UNCLEAR whenever we should use `$engine->destroyObject(PhabricatorFileAttachment)` or just `PhabricatorFileAttachment#delete()`
----
Thanks for any comment ๐