@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<?php
2
3final class FileDeletionWorker extends PhabricatorWorker {
4
5 private function loadFile() {
6 $phid = idx($this->getTaskData(), 'objectPHID');
7 if (!$phid) {
8 throw new PhabricatorWorkerPermanentFailureException(
9 pht('No "%s" in task data.', 'objectPHID'));
10 }
11
12 $file = id(new PhabricatorFileQuery())
13 ->setViewer(PhabricatorUser::getOmnipotentUser())
14 ->withPHIDs(array($phid))
15 ->executeOne();
16
17 if (!$file) {
18 throw new PhabricatorWorkerPermanentFailureException(
19 pht('File "%s" does not exist.', $phid));
20 }
21
22 return $file;
23 }
24
25 protected function doWork() {
26 $file = $this->loadFile();
27 $engine = new PhabricatorDestructionEngine();
28 $engine->destroyObject($file);
29 }
30
31}