@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 PhabricatorConfigPurgeCacheController
4 extends PhabricatorConfigController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
8 $cancel_uri = $this->getApplicationURI('cache/');
9
10 $opcode_cache = PhabricatorOpcodeCacheSpec::getActiveCacheSpec();
11 $data_cache = PhabricatorDataCacheSpec::getActiveCacheSpec();
12
13 $opcode_clearable = $opcode_cache->getClearCacheCallback();
14 $data_clearable = $data_cache->getClearCacheCallback();
15
16 if (!$opcode_clearable && !$data_clearable) {
17 return $this->newDialog()
18 ->setTitle(pht('No Caches to Reset'))
19 ->appendParagraph(
20 pht('None of the caches on this page can be cleared.'))
21 ->addCancelButton($cancel_uri);
22 }
23
24 if ($request->isDialogFormPost()) {
25 if ($opcode_clearable) {
26 call_user_func($opcode_cache->getClearCacheCallback());
27 }
28
29 if ($data_clearable) {
30 call_user_func($data_cache->getClearCacheCallback());
31 }
32
33 return id(new AphrontRedirectResponse())->setURI($cancel_uri);
34 }
35
36 $caches = id(new PHUIPropertyListView())
37 ->setUser($viewer);
38
39 if ($opcode_clearable) {
40 $caches->addProperty(
41 pht('Opcode'),
42 $opcode_cache->getName());
43 }
44
45 if ($data_clearable) {
46 $caches->addProperty(
47 pht('Data'),
48 $data_cache->getName());
49 }
50
51 return $this->newDialog()
52 ->setTitle(pht('Really Clear Cache?'))
53 ->setShortTitle(pht('Really Clear Cache'))
54 ->appendParagraph(pht('This will only affect the current web '.
55 'frontend. Daemons and any other web frontends may continue '.
56 'to use older, cached code from their opcache.'))
57 ->appendParagraph(pht('The following caches will be cleared:'))
58 ->appendChild($caches)
59 ->addSubmitButton(pht('Clear Cache'))
60 ->addCancelButton($cancel_uri);
61 }
62}