Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/storage/PhabricatorFile.php
Show First 20 Lines • Show All 1,699 Lines • ▼ Show 20 Lines | |||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */ | /* -( PhabricatorDestructibleInterface )----------------------------------- */ | ||||
public function destroyObjectPermanently( | public function destroyObjectPermanently( | ||||
PhabricatorDestructionEngine $engine) { | PhabricatorDestructionEngine $engine) { | ||||
$this->openTransaction(); | $this->openTransaction(); | ||||
$attachments = id(new PhabricatorFileAttachment())->loadAllWhere( | |||||
'filePHID = %s', | |||||
$this->getPHID()); | |||||
valerio.bozzolan: ✅ Note that I like that you have built this query in the raw way, instead of using… | |||||
foreach ($attachments as $attachment) { | |||||
$attachment->delete(); | |||||
Not Done Inline ActionsI don't like using mpull for the side-effect of the method invoked. avivey: I don't like using `mpull` for the side-effect of the method invoked. | |||||
Not Done Inline ActionsI agree, also because it returns an array of [null, null, null, null] which is not useful to read. A simple foreach() may be better valerio.bozzolan: I agree, also because it returns an array of `[null, null, null, null]` which is not useful to… | |||||
} | |||||
$this->delete(); | $this->delete(); | ||||
$this->saveTransaction(); | $this->saveTransaction(); | ||||
} | } | ||||
/* -( PhabricatorConduitResultInterface )---------------------------------- */ | /* -( PhabricatorConduitResultInterface )---------------------------------- */ | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
✅ Note that I like that you have built this query in the raw way, instead of using PhabricatorFileAttachmentQuery() since in the raw way it does not try to pull the objects, and, it will not discard results if objects are already deleted for some reasons, and, there is no extra overhead for the omnipotent user thing.