-
Notifications
You must be signed in to change notification settings - Fork 1
/
apc.install
63 lines (53 loc) · 2.11 KB
/
apc.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* Implements hook_requirements().
*/
function apc_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time
$t = get_t();
// Test APC.
$apc_enabled = (function_exists('apc_cache_info') && ($cache = @apc_cache_info('user', TRUE)));
if (extension_loaded('apcu')) {
$version = phpversion('apcu');
$name = $t('APCu');
$description = $t('APC needs APCu version >=4.0.2.');
$meets_version = version_compare($version, '4.0.2') >= 0;
// APCu reports cache info with keys that differ from APC.
// This has been fixed upstream, but has not made it into a release.
// @see https://github.com/krakjoe/apcu/issues/41
// @see https://github.com/krakjoe/apcu/pull/42
$cache['num_entries'] = isset($cache['num_entries']) ? $cache['num_entries'] : $cache['nentries'];
$cache['start_time'] = isset($cache['start_time']) ? $cache['start_time'] : $cache['stime'];
}
else {
$version = phpversion('apc');
$name = $t('APCu');
$description = $t('APC needs version >=3.1.1.');
$meets_version = version_compare($version, '3.1.1') >= 0;
}
$requirements['apc'] = array(
'title' => $name,
'value' => $apc_enabled ? ($meets_version ? $version : $description) : $t('Not available'),
'severity' => $apc_enabled && $meets_version ? ($cache['num_entries'] ? REQUIREMENT_OK : REQUIREMENT_WARNING) : REQUIREMENT_ERROR,
);
if ($apc_enabled) {
$requirements['apc']['description'] = $t('!name has been running for !duration. Currently caching !num_entries entries (!memory_size).',
array(
'!name' => $name,
'!duration' => format_interval(time() - $cache['start_time']),
'!num_entries' => $cache['num_entries'],
'!memory_size' => format_size($cache['mem_size']),
)
);
}
else {
$requirements['apc']['description'] = $t('The APC module needs the <a href="!apc_link">APC</a> or the <a href="!apcu_link">APCu</a> extension.',
array(
'!apc_link' => 'http://www.php.net/apc',
'!apcu_link' => 'https://github.com/krakjoe/apcu',
)
);
}
return $requirements;
}