Issue #3466399 by mfb, taran2l, eporama: APCu requirement for 32M is checking wrong value

merge-requests/5505/head^2
catch 2024-08-19 09:27:11 +09:00
parent 8a74cf6164
commit 8705b9ab24
2 changed files with 14 additions and 3 deletions

View File

@ -408,10 +408,10 @@ function system_requirements($phase) {
$requirements['php_apcu_available']['title'] = t('PHP APCu available caching');
if (extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) {
$memory_info = apcu_sma_info(TRUE);
$apcu_actual_size = ByteSizeMarkup::create($memory_info['seg_size']);
$apcu_actual_size = ByteSizeMarkup::create($memory_info['seg_size'] * $memory_info['num_seg']);
$apcu_recommended_size = '32 MB';
$requirements['php_apcu_enabled']['value'] = t('Enabled (@size)', ['@size' => $apcu_actual_size]);
if ($memory_info['seg_size'] < Bytes::toNumber($apcu_recommended_size)) {
if (Bytes::toNumber(ini_get('apc.shm_size')) * ini_get('apc.shm_segments') < Bytes::toNumber($apcu_recommended_size)) {
$requirements['php_apcu_enabled']['severity'] = REQUIREMENT_WARNING;
$requirements['php_apcu_enabled']['description'] = t('Depending on your configuration, Drupal can run with a @apcu_size APCu limit. However, a @apcu_default_size APCu limit (the default) or above is recommended, especially if your site uses additional custom or contributed modules.', [
'@apcu_size' => $apcu_actual_size,
@ -419,7 +419,7 @@ function system_requirements($phase) {
]);
}
else {
$memory_available = $memory_info['avail_mem'] / $memory_info['seg_size'];
$memory_available = $memory_info['avail_mem'] / ($memory_info['seg_size'] * $memory_info['num_seg']);
if ($memory_available < 0.1) {
$requirements['php_apcu_available']['severity'] = REQUIREMENT_ERROR;
$requirements['php_apcu_available']['description'] = t('APCu is using over 90% of its allotted memory (@apcu_actual_size). To improve APCu performance, consider increasing this limit.', [

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\Tests\system\Functional\System;
use Drupal\Component\Utility\Bytes;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
@ -188,6 +189,16 @@ class StatusTest extends BrowserTestBase {
$this->assertCount(1, $elements);
$this->assertStringStartsWith('Available', $elements[0]->getParent()->getText());
}
// Test APCu status.
$elements = $this->xpath('//details[summary[contains(@class, "system-status-report__status-title") and normalize-space(text()) = "PHP APCu caching"]]/div[@class="system-status-report__entry__value"]/text()');
// Ensure the status is not a warning if APCu size is greater than or equal
// to the recommended size.
if (preg_match('/^Enabled \((.*)\)$/', $elements[0]->getText(), $matches)) {
if (Bytes::toNumber($matches[1]) >= 1024 * 1024 * 32) {
$this->assertFalse($elements[0]->find('xpath', '../../summary')->hasClass('system-status-report__status-icon--warning'));
}
}
}
/**