@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 DiffusionPathValidateController extends DiffusionController {
4
5 protected function getRepositoryIdentifierFromRequest(
6 AphrontRequest $request) {
7 return $request->getStr('repositoryPHID');
8 }
9
10 public function handleRequest(AphrontRequest $request) {
11 $response = $this->loadDiffusionContext();
12 if ($response) {
13 return $response;
14 }
15
16 $viewer = $this->getViewer();
17 $drequest = $this->getDiffusionRequest();
18 $repository = $drequest->getRepository();
19
20 $path = $request->getStr('path');
21 $path = ltrim($path, '/');
22
23 $browse_results = DiffusionBrowseResultSet::newFromConduit(
24 $this->callConduitWithDiffusionRequest(
25 'diffusion.browsequery',
26 array(
27 'path' => $path,
28 'commit' => $drequest->getCommit(),
29 'needValidityOnly' => true,
30 )));
31 $valid = $browse_results->isValidResults();
32
33 if (!$valid) {
34 switch ($browse_results->getReasonForEmptyResultSet()) {
35 case DiffusionBrowseResultSet::REASON_IS_EMPTY:
36 case DiffusionBrowseResultSet::REASON_IS_FILE:
37 $valid = true;
38 break;
39 }
40 }
41
42 $output = array(
43 'valid' => (bool)$valid,
44 );
45
46 return id(new AphrontAjaxResponse())->setContent($output);
47 }
48}