Skip to content

fix(php8): remove duplicate OPcache loader on PHP <= 8.4#91

Open
lussoluca wants to merge 2 commits into
masterfrom
fix/duplicate-opcache-load
Open

fix(php8): remove duplicate OPcache loader on PHP <= 8.4#91
lussoluca wants to merge 2 commits into
masterfrom
fix/duplicate-opcache-load

Conversation

@lussoluca

@lussoluca lussoluca commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

🤖 This was written by an AI agent on behalf of @lussoluca.

Problem

Since e9b6e49 ("feat(php8): add PHP 8.5.7 and refresh image dependencies"), the 8.x image emits at every PHP invocation:

Cannot load Zend OPcache - it was already loaded

Reproduced on the 8.4.22-fpm-alpine3.24-rootless tag. The 8.4.2 tag (built before that commit) is clean.

Root cause

The official parent php:8.x-fpm-alpine image already enables OPcache via docker-php-ext-opcache.ini (zend_extension=opcache). Commit e9b6e49 added a second loader:

RUN if [ -f "$(php -r 'echo ini_get("extension_dir");')/opcache.so" ]; then \ echo "zend_extension=opcache.so" > /usr/local/etc/php/conf.d/00-opcache-load.ini; \ fi

On PHP <= 8.4 both loaders run → OPcache loads twice → the warning. On PHP 8.5 OPcache is statically compiled, opcache.so is absent, so the guard never created the file there. The block only ever fired on <= 8.4, exactly where the parent already loads OPcache — always redundant.

Fix

Remove the block. opcache.ini still tunes OPcache in both cases (it carries no zend_extension line); the parent loads it on <= 8.4 and it is static on 8.5.

Additional cleanup: drop dead opcache.fast_shutdown

8/conf/opcache.ini set opcache.fast_shutdown=1. That directive was removed in PHP 7.2 — fast shutdown became always-on and the option no longer exists. On PHP 8.4 it is absent from phpinfo() and ini_get("opcache.fast_shutdown") returns false, so the line is silently ignored dead config. The 8/ image only targets PHP 8.x, so it can never apply. Removed.

Verification

In the affected 8.4.22 image, two loaders are present:

/usr/local/etc/php/conf.d/00-opcache-load.ini:     zend_extension=opcache.so
/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini: zend_extension=opcache

After this change only the parent's docker-php-ext-opcache.ini remains, OPcache stays enabled, and the warning is gone. Verified locally by building the PR branch (--build-arg PHPVER=8.4.22-fpm-alpine3.24, targets dist and dev): single loader, no warning, extension_loaded("Zend OPcache")true, and opcache_get_status()["opcache_enabled"]true with opcache.enable_cli=1.

Assisted-by: claude-code/claude-opus-4-8

The official php:8.x-fpm image already enables OPcache via
docker-php-ext-opcache.ini (zend_extension=opcache). Adding a second
00-opcache-load.ini (zend_extension=opcache.so) made PHP load OPcache
twice on PHP <= 8.4, emitting 'Cannot load Zend OPcache - it was already
loaded' at every invocation.

On PHP 8.5 OPcache is statically compiled, so the guard never created the
file there anyway. The block only ever fired on <= 8.4, exactly where the
parent image already loads OPcache, so it was always redundant.

opcache.ini still tunes OPcache in both cases; it carries no zend_extension
line.

Assisted-by: claude-code/claude-opus-4-8
@sparkfabrik-ai-bot

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

OPcache on PHP 8.5

After removing the block, verify that OPcache is properly enabled and functional on PHP 8.5 builds. The PR description states OPcache is statically compiled on 8.5, but it should be confirmed that the opcache.ini tuning file still applies correctly and OPcache is active without any additional loader configuration.

COPY conf/*.ini /usr/local/etc/php/conf.d/
COPY conf.disabled /usr/local/etc/php/conf.disabled
COPY fpm-conf-templates/ /templates/

# Make folders writable for the root group
RUN chmod 775 /usr/local/etc/php && \
    chmod 775 /usr/local/etc/php/conf.d && \
    chmod 775 /usr/local/etc/php-fpm.d && \

@sparkfabrik-ai-bot

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@lussoluca lussoluca requested a review from Monska85 June 16, 2026 07:02
opcache.fast_shutdown was removed in PHP 7.2 — fast shutdown became
always-on and the directive no longer exists. PHP 8.4 does not list it in
phpinfo() and ini_get() returns false, so the line in 8/conf/opcache.ini is
silently ignored dead config. The 8/ image only targets PHP 8.x, so it can
never apply. Remove it.

Assisted-by: claude-code/claude-opus-4-8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant