Skip to content

Make opcache.enable configurable via PHP_OPCACHE_ENABLE - #3

Merged
michaelaguiar merged 1 commit into
mainfrom
add-opcache-enable-knob
Sep 11, 2026
Merged

michaelaguiar merged 1 commit into
mainfrom
add-opcache-enable-knob

Conversation

@michaelaguiar

Copy link
Copy Markdown
Member

What

opcache.enable was the one hardcoded value in docker-configure among env-driven neighbours:

-    echo "opcache.enable = 1"
+    echo "opcache.enable = ${PHP_OPCACHE_ENABLE:-1}"

plus ENV PHP_OPCACHE_ENABLE=1 in the four frankenphp base Dockerfiles (8.2–8.5). WordPress and dev variants are FROM the base, so they inherit it with no edit.

Why it's not a deliberate safety decision

1e756b1 originally hardcoded every opcache value — memory_consumption, validate_timestamps, jit, jit_buffer_size. Later work parameterized the rest and simply didn't reach this line.

Disabling opcache in production remains a bad idea, but the blast radius was already reachable: PHP_OPCACHE_MEMORY=1 or PHP_OPCACHE_MAX_FILES=1 are just as silently catastrophic and have always been exposed. The real use for the knob is CI and debugging — opcache's optimizer distorts line-level code coverage.

No behavior change

The ${PHP_OPCACHE_ENABLE:-1} fallback means an unset var still yields opcache.enable = 1, so existing images and running containers are unaffected. Same fallback discipline the file already commits to for JIT at docker-configure:29-33.

Verified against ghcr.io/aliasproject/php:8.4-frankenphp:

Case app.ini ini_get()
unset (fallback) opcache.enable = 1 —
PHP_OPCACHE_ENABLE=0 opcache.enable = 0 0

Drive-by CI fix

detect-changes watched the Dockerfile paths but not docker-configure — so a change to that file alone would have silently shipped nothing, despite it rendering all of app.ini at container boot. Added it to the watched paths and to the 20 job conditions that key off the base Dockerfile, so base, dev and wordpress variants all rebuild when it changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MuahHB9waqScWSrf9UxpvL

Every other opcache setting in docker-configure is env-driven, but
opcache.enable was left as a literal. It isn't a deliberate safety
decision: 1e756b1 originally hardcoded all of them (memory_consumption,
validate_timestamps, jit, ...) and later work parameterized the rest
without reaching this line.

Defaults to 1 via ${PHP_OPCACHE_ENABLE:-1}, so behavior is unchanged for
every existing image and container -- an unset var still yields
opcache.enable = 1. This follows the same fallback discipline the file
already commits to for JIT: if the env var is missing, fall back to the
safe value rather than PHP's own default.

The knob matters for CI and debugging: opcache's optimizer distorts
line-level code coverage, which is the usual reason to want it off.
Disabling opcache in production remains a bad idea, but the blast radius
was already reachable -- PHP_OPCACHE_MEMORY=1 or PHP_OPCACHE_MAX_FILES=1
are just as silently catastrophic and have always been exposed.

Also fix a CI gap found along the way: detect-changes watched the
Dockerfile paths but not docker-configure, so a change to that file
alone would have silently shipped nothing despite it rendering all of
app.ini at container boot. Added it to the watched paths and to the 20
job conditions that key off the base Dockerfile, so base, dev and
wordpress variants all rebuild when it changes.

Verified against ghcr.io/aliasproject/php:8.4-frankenphp: unset -> 1,
PHP_OPCACHE_ENABLE=0 -> 0 in app.ini and in ini_get() at runtime.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MuahHB9waqScWSrf9UxpvL
@michaelaguiar
michaelaguiar merged commit f99bfd3 into main Sep 11, 2026
2 checks passed
@michaelaguiar
michaelaguiar deleted the add-opcache-enable-knob branch September 11, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant