Skip to content
Snippets Groups Projects
Commit bccb4644 authored by Alberto Paderno's avatar Alberto Paderno
Browse files

Issue #3472280: Increase the mimimum required PHP version and the minimum APCu extension version

parent 7ecadded
No related branches found
No related tags found
1 merge request!79Issue #3472280: Increase the mimimum required PHP version and the minimum APCu extension version
Pipeline #274540 passed
......@@ -28,5 +28,6 @@ include:
# OPT_IN_TEST_NEXT_MAJOR: '1'
# _CURL_TEMPLATES_REF: 'main'
variables:
PHP_VERSION: '8.2'
_PHPUNIT_CONCURRENT: '1'
_CONCURRENCY_THREADS: '6'
......@@ -17,7 +17,7 @@
<path value="$PROJECT_DIR$/../drupal/sites/all/modules" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration">
<component name="PhpProjectSharedConfiguration" php_language_level="8.2">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
<component name="PhpStanOptionsConfiguration">
......
......@@ -2,6 +2,7 @@ name = Alternative PHP Cache
description = Integrates the APCu extension with Drupal.
package = Performance and scalability
core = 7.x
php = 8.2
files[] = apc.test
files[] = includes/classes/apc_cache.inc
files[] = includes/classes/apc_lock.inc
......@@ -18,7 +18,6 @@
* patterns are replaced by the new patterns.
*/
function _apc_delete_apcu_keys($patterns = array()) {
$apcu_enabled = extension_loaded('apcu') && apcu_enabled();
$apcu_keys_to_remove = variable_get('apc_apcu_keys_to_remove', array());
foreach ($patterns as $pattern => $old_pattern) {
......@@ -33,7 +32,7 @@ function _apc_delete_apcu_keys($patterns = array()) {
// code to terminate.
variable_set('apc_apcu_keys_to_remove', $apcu_keys_to_remove);
if ($apcu_enabled && class_exists('APCUIterator')) {
if (extension_loaded('apcu') && apcu_enabled()) {
foreach (array_keys($apcu_keys_to_remove) as $pattern) {
$pattern = '/^' . preg_quote($pattern, '/') . '/';
$iterator = new APCUIterator($pattern, APC_ITER_KEY);
......@@ -70,11 +69,11 @@ function apc_requirements($phase) {
return $requirements;
}
$required_version_installed = version_compare($apcu_version, '5.0.0', '>=');
$required_version_installed = version_compare($apcu_version, '5.1.17', '>=');
if (!$required_version_installed) {
$requirements['apc']['description'] = $t(
'The Alternative PHP Cache module needs the APCu extension version 5.0.0 or higher; version %apcu_version is currently installed.',
'The Alternative PHP Cache module needs the APCu extension version 5.1.17 or higher; version %apcu_version is currently installed.',
array('%apcu_version' => $apcu_version)
);
$requirements['apc']['severity'] = REQUIREMENT_ERROR;
......@@ -146,9 +145,7 @@ function apc_update_7201() {
* Implements hook_uninstall().
*/
function apc_uninstall() {
$apcu_enabled = extension_loaded('apcu') && apcu_enabled();
if ($apcu_enabled && class_exists('APCUIterator')) {
if (extension_loaded('apcu') && apcu_enabled()) {
$cache_iterator = new APCUIterator('/^apc_cache::[a-zA-Z0-9-_]{40,46}::[0-9a-f]{2,}/', APC_ITER_KEY);
$lock_iterator = new APCUIterator('/^apc_lock::[a-zA-Z0-9-_]{40,46}/', APC_ITER_KEY);
......
......@@ -5,8 +5,6 @@
* Test classes for the Alternative PHP Cache module.
*/
// phpcs:disable SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator.NullCoalesceOperatorNotUsed
/**
* Methods and properties for all the test classes that write directly to APCu.
*/
......@@ -301,7 +299,7 @@ trait ApcApcuTestTrait {
protected function assertApcuKeysByPrefix($key, $options = array()) {
$escaped_key = preg_quote($key, '/');
$iterator = new APCUIterator("/^$escaped_key/", APC_ITER_KEY);
$message = isset($options['message']) ? $options['message'] : 'There are APCu keys matching @key.';
$message = $options['message'] ?? 'There are APCu keys matching @key.';
$message = format_string($message, array('@key' => $this->varExport("/^$escaped_key/")));
return $this->assertTrue($iterator->getTotalCount() > 0, $message);
......@@ -323,7 +321,7 @@ trait ApcApcuTestTrait {
protected function assertNoApcuKeysByPrefix($key, $options = array()) {
$escaped_key = preg_quote($key, '/');
$iterator = new APCUIterator("/^$escaped_key/", APC_ITER_KEY);
$message = isset($options['message']) ? $options['message'] : 'There are no APCu keys matching @key.';
$message = $options['message'] ?? 'There are no APCu keys matching @key.';
$message = format_string($message, array('@key' => $this->varExport("/^$escaped_key/")));
return $this->assertTrue($iterator->getTotalCount() === 0, $message);
......
......@@ -5,8 +5,6 @@
* Contains ApcCache.
*/
// phpcs:disable SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator.NullCoalesceOperatorNotUsed
/**
* APCu cache implementation.
*
......@@ -69,11 +67,6 @@ protected function binaryToHex($data) {
protected function setBinPrefix() {
$prefixes = variable_get('apc_cache_prefix', '');
// @todo Remove the following lines in the 7.x-2.x branch.
if (empty($prefixes)) {
$prefixes = variable_get('cache_prefix', '');
}
if (is_string($prefixes) && !empty($prefixes)) {
// $prefixes can be a string used for all the cache bins.
$this->prefixes[0] = $this->binaryToHex($prefixes);
......@@ -334,7 +327,7 @@ public function clear($cid = NULL, $wildcard = FALSE) {
* {@inheritdoc}
*/
public function isEmpty() {
if (extension_loaded('apcu') && apcu_enabled() && class_exists('APCUIterator')) {
if (extension_loaded('apcu') && apcu_enabled()) {
$escaped_key = preg_quote($this->keyName(), '/');
$iterator = new APCUIterator('/^' . $escaped_key . '/', APC_ITER_KEY);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment