Unverified Commit 60782706 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3538854 by dww, driskell, andypost, godotislate: APCu requirement for...

Issue #3538854 by dww, driskell, andypost, godotislate: APCu requirement for 32MB always displays since APCu 5.1.25
parent edbbe5c1
Loading
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -397,11 +397,15 @@ public static function checkRequirements(string $phase): array {
      $requirements['php_apcu_enabled']['title'] = t('PHP APCu caching');
      $requirements['php_apcu_available']['title'] = t('PHP APCu available caching');
      if (extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) {
        // The apc.shm_segments ini option was removed in APCu 5.1.25, so fall
        // back to 1 if ini_get('apc.shm_segments') is empty.
        // @see https://pecl.php.net/package/APCu/5.1.25
        $apcu_shm_segments = ini_get('apc.shm_segments') ?: 1;
        $memory_info = apcu_sma_info(TRUE);
        $apcu_actual_size = ByteSizeMarkup::create($memory_info['seg_size'] * $memory_info['num_seg']);
        $apcu_actual_size = ByteSizeMarkup::create($memory_info['seg_size'] * $apcu_shm_segments);
        $apcu_recommended_size = '32 MB';
        $requirements['php_apcu_enabled']['value'] = t('Enabled (@size)', ['@size' => $apcu_actual_size]);
        if (Bytes::toNumber(ini_get('apc.shm_size')) * ini_get('apc.shm_segments') < Bytes::toNumber($apcu_recommended_size)) {
        if ((Bytes::toNumber(ini_get('apc.shm_size')) * $apcu_shm_segments) < Bytes::toNumber($apcu_recommended_size)) {
          $requirements['php_apcu_enabled']['severity'] = RequirementSeverity::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,
@@ -409,7 +413,7 @@ public static function checkRequirements(string $phase): array {
          ]);
        }
        else {
          $memory_available = $memory_info['avail_mem'] / ($memory_info['seg_size'] * $memory_info['num_seg']);
          $memory_available = $memory_info['avail_mem'] / ($memory_info['seg_size'] * $apcu_shm_segments);
          if ($memory_available < 0.1) {
            $requirements['php_apcu_available']['severity'] = RequirementSeverity::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.', [
+0 −1
Original line number Diff line number Diff line
@@ -199,7 +199,6 @@ public function testStatusPage(): void {
    }

    // Test APCu status.
    $this->markTestSkipped('Skipped due to bugs with APUc size warnings. See https://www.drupal.org/project/drupal/issues/3539331');
    $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.