@@ -15,81 +15,70 @@ public function getCacheSummary() {
15
15
16
16
public static function getActiveCacheSpec () {
17
17
$ spec = new PhabricatorDataCacheSpec ();
18
+
18
19
// NOTE: If APCu is installed, it reports that APC is installed.
19
20
if (extension_loaded ('apc ' ) && !extension_loaded ('apcu ' )) {
20
- return self :: getAPCSpec ( $ spec );
21
+ $ spec-> initAPCSpec ( );
21
22
} else if (extension_loaded ('apcu ' )) {
22
- return self :: getAPCuSpec ( $ spec );
23
+ $ spec-> initAPCuSpec ( );
23
24
} else {
24
- return self :: getNoneSpec ( $ spec );
25
+ $ spec-> initNoneSpec ( );
25
26
}
27
+
28
+ return $ spec ;
26
29
}
27
30
28
- private static function getAPCSpec ( PhabricatorDataCacheSpec $ spec ) {
29
- $ spec
31
+ private function initAPCSpec ( ) {
32
+ $ this
30
33
->setName (pht ('APC User Cache ' ))
31
34
->setVersion (phpversion ('apc ' ));
32
35
33
36
if (ini_get ('apc.enabled ' )) {
34
- $ spec ->setIsEnabled (true );
35
- self :: getAPCCommonSpec ( $ spec );
37
+ $ this ->setIsEnabled (true );
38
+ $ this -> initAPCCommonSpec ( );
36
39
} else {
37
- $ spec ->setIsEnabled (false );
38
- $ spec ->newIssue (
39
- pht ('Enable APC ' ),
40
- pht (
41
- 'The "APC" extension is currently disabled. Set "apc.enabled" to ' .
42
- 'true to provide caching. ' ),
43
- 'apc.enabled ' );
40
+ $ this ->setIsEnabled (false );
41
+ $ this ->raiseEnableAPCIssue ();
44
42
}
45
-
46
- return $ spec ;
47
43
}
48
44
49
- private static function getAPCuSpec ( PhabricatorDataCacheSpec $ spec ) {
50
- $ spec
45
+ private function initAPCuSpec ( ) {
46
+ $ this
51
47
->setName (pht ('APCu ' ))
52
48
->setVersion (phpversion ('apcu ' ));
53
49
54
50
if (ini_get ('apc.enabled ' )) {
55
- $ spec ->setIsEnabled (true );
56
- self :: getAPCCommonSpec ($ spec );
51
+ $ this ->setIsEnabled (true );
52
+ $ this -> getAPCCommonSpec ();
57
53
} else {
58
- $ spec ->setIsEnabled (false );
59
- $ spec ->newissue (
60
- pht ('Enable APCu ' ),
61
- pht (
62
- 'The "APCu" extension is currently disabled. Set ' .
63
- '"apc.enabled" to true to provide caching. ' ),
64
- 'apc.enabled ' );
54
+ $ this ->setIsEnabled (false );
55
+ $ this ->raiseEnableAPCIssue ();
65
56
}
66
-
67
- return $ spec ;
68
57
}
69
58
70
- private static function getNoneSpec (PhabricatorDataCacheSpec $ spec ) {
59
+ private function getNoneSpec () {
71
60
if (version_compare (phpversion (), '5.5 ' , '>= ' )) {
72
- $ spec ->newIssue (
73
- pht ('Install APCu ' ),
74
- pht (
75
- 'Install the "APCu" PHP extension to provide data caching. ' ));
61
+ $ message = pht (
62
+ 'Installing the "APCu" PHP extension will improve performance. ' );
63
+
64
+ $ this
65
+ ->newIssue ('extension.apcu ' )
66
+ ->setShortName (pht ('APCu ' ))
67
+ ->setName (pht ('PHP Extension "APCu" Not Installed ' ))
68
+ ->setMessage ($ message )
69
+ ->addPHPExtension ('apcu ' );
76
70
} else {
77
- $ spec ->newIssue (
78
- pht ('Install APC ' ),
79
- pht (
80
- 'Install the "APC" PHP extension to provide data caching. ' ));
71
+ $ this ->raiseInstallAPCIssue ();
81
72
}
82
-
83
- return $ spec ;
84
73
}
85
74
86
- private static function getAPCCommonSpec (PhabricatorDataCacheSpec $ spec ) {
75
+ private function getAPCCommonSpec () {
87
76
$ mem = apc_sma_info ();
88
- $ spec ->setTotalMemory ($ mem ['num_seg ' ] * $ mem ['seg_size ' ]);
77
+ $ this ->setTotalMemory ($ mem ['num_seg ' ] * $ mem ['seg_size ' ]);
89
78
90
79
$ info = apc_cache_info ('user ' );
91
- $ spec ->setUsedMemory ($ info ['mem_size ' ]);
92
- $ spec ->setEntryCount (count ($ info ['cache_list ' ]));
80
+ $ this ->setUsedMemory ($ info ['mem_size ' ]);
81
+ $ this ->setEntryCount (count ($ info ['cache_list ' ]));
93
82
94
83
$ cache = $ info ['cache_list ' ];
95
84
$ state = array ();
@@ -107,7 +96,7 @@ private static function getAPCCommonSpec(PhabricatorDataCacheSpec $spec) {
107
96
$ state [$ key ]['count ' ]++;
108
97
}
109
98
110
- $ spec ->setCacheSummary ($ state );
99
+ $ this ->setCacheSummary ($ state );
111
100
}
112
101
113
102
private static function getKeyPattern ($ key ) {
0 commit comments