APCu detection erroneously succeeds if apc.enabled is "0"

Created on 7 March 2015, almost 10 years ago
Updated 30 September 2024, 3 months ago

Remove all todos that point to this issue.

Problem/Motivation

Drupal uses function_exists('apc_fetch') to detect the APCu backend.

There're two problems with that:

  1. The detection doesn't verify the ini settings like apc.enabled. In some environments this leads to an usage of APCu even if it's disabled which might lead to any kind of problems. => critical
  2. Unfortunately this also uses APC on a pure APC backend, which has a track record of not working well, because the user cache is combined with the opcode cache and such leads to strong fragmentation.
    There is two things to discuss here:
    • Pro - enabling also for APC itself (non APCu)
      • apc_fetch is still faster than the DB
      • The chained fast backend can be used
    • Contra
      • Strong fragmentation influences the opcode cache
      • That can lead to reduced file and especially class loading times

Proposed resolution

  • Use extension_loaded('apcu') to detect the APC backend only for APCu. (Likely need a helper for this somewhere, which can be configured or overridden.)
  • Verify the ini settings (see comment #15)

Remaining tasks

User interface changes

API changes

Original report

Follow up to #2395143: YAML parsing is very slow, cache it with FileCache β†’

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡¦πŸ‡ΊAustralia dashaforbes

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • pere orga Catalonia

    I think the standard nowadays (APCu >= 4.0.3) would be to check the following:

    extension_loaded('apcu') && apcu_enabled()

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    πŸ‘ yes this is correct as far as I know - I use extension_loaded('apcu') && apcu_enabled() in a contrib module, and we're way beyond APCu 4.x, as 5.x is required for PHP 7 (much less PHP 8)

Production build 0.71.5 2024