@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 DifferentialRevisionEditController
4 extends DifferentialController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
8
9 // If we have a Diff ID, this is an "/attach/123/to/456/" action. The
10 // user just created a diff and is trying to use it to create or update
11 // a revision.
12 $diff_id = $request->getURIData('diffID');
13
14 if ($diff_id) {
15 $diff = id(new DifferentialDiffQuery())
16 ->setViewer($viewer)
17 ->withIDs(array($diff_id))
18 ->executeOne();
19 if (!$diff) {
20 return new Aphront404Response();
21 }
22
23 if ($diff->getRevisionID()) {
24 $revision = $diff->getRevision();
25 return $this->newDialog()
26 ->setTitle(pht('Diff Already Attached'))
27 ->appendParagraph(
28 pht(
29 'This diff is already attached to a revision.'))
30 ->addCancelButton($revision->getURI(), pht('Continue'));
31 }
32 } else {
33 $diff = null;
34 }
35
36 $revision_id = $request->getURIData('id');
37 if (!$diff && !$revision_id) {
38 return $this->newDialog()
39 ->setTitle(pht('Diff Required'))
40 ->appendParagraph(
41 pht(
42 'You can not create a revision without a diff.'))
43 ->addCancelButton($this->getApplicationURI());
44 }
45
46 $engine = id(new DifferentialRevisionEditEngine())
47 ->setController($this);
48
49 if ($diff) {
50 $engine->setDiff($diff);
51 }
52
53 return $engine->buildResponse();
54 }
55
56}