@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
3abstract class PhabricatorCacheSpec extends Phobject {
4
5 private $name;
6 private $isEnabled = false;
7 private $version;
8 private $clearCacheCallback = null;
9 private $issues = array();
10
11 private $usedMemory = 0;
12 private $totalMemory = 0;
13 private $entryCount = null;
14
15 public function setName($name) {
16 $this->name = $name;
17 return $this;
18 }
19
20 public function getName() {
21 return $this->name;
22 }
23
24 public function setIsEnabled($is_enabled) {
25 $this->isEnabled = $is_enabled;
26 return $this;
27 }
28
29 public function getIsEnabled() {
30 return $this->isEnabled;
31 }
32
33 public function setVersion($version) {
34 $this->version = $version;
35 return $this;
36 }
37
38 public function getVersion() {
39 return $this->version;
40 }
41
42 protected function newIssue($key) {
43 $issue = id(new PhabricatorSetupIssue())
44 ->setIssueKey($key);
45 $this->issues[$key] = $issue;
46
47 return $issue;
48 }
49
50 public function getIssues() {
51 return $this->issues;
52 }
53
54 public function setUsedMemory($used_memory) {
55 $this->usedMemory = $used_memory;
56 return $this;
57 }
58
59 public function getUsedMemory() {
60 return $this->usedMemory;
61 }
62
63 public function setTotalMemory($total_memory) {
64 $this->totalMemory = $total_memory;
65 return $this;
66 }
67
68 public function getTotalMemory() {
69 return $this->totalMemory;
70 }
71
72 public function setEntryCount($entry_count) {
73 $this->entryCount = $entry_count;
74 return $this;
75 }
76
77 public function getEntryCount() {
78 return $this->entryCount;
79 }
80
81 protected function raiseEnableAPCIssue() {
82 $summary = pht('Enabling APCu will improve performance.');
83 $message = pht(
84 'The APCu PHP extension is installed, but not enabled in your '.
85 'PHP configuration. Enabling this extension will improve performance. '.
86 'Edit the "%s" setting to enable this extension.',
87 'apc.enabled');
88
89 return $this
90 ->newIssue('extension.apc.enabled')
91 ->setShortName(pht('APCu Disabled'))
92 ->setName(pht('APCu Extension Not Enabled'))
93 ->setSummary($summary)
94 ->setMessage($message)
95 ->addPHPConfig('apc.enabled');
96 }
97
98 public function setClearCacheCallback($callback) {
99 $this->clearCacheCallback = $callback;
100 return $this;
101 }
102
103 public function getClearCacheCallback() {
104 return $this->clearCacheCallback;
105 }
106}