Skip to content

Fix PHP 8.5 upgrade being falsely reported as a downgrade - #2596

Open
sharyaropensource wants to merge 1 commit into
nextcloud:masterfrom
sharyaropensource:fix/php85-opcache-upgrade
Open

Fix PHP 8.5 upgrade being falsely reported as a downgrade#2596
sharyaropensource wants to merge 1 commit into
nextcloud:masterfrom
sharyaropensource:fix/php85-opcache-upgrade

Conversation

@sharyaropensource

Copy link
Copy Markdown

Summary

Fixes #2595 — upgrading Nextcloud on the PHP 8.5 base image fails with:

Can't start Nextcloud because the version of the data (...) is higher than the docker image version (...) and downgrading is not supported.

Root cause

In PHP 8.5 the opcache extension is statically compiled into the official base image, so there is no opcache.so and the PHP 8.4-style docker-php-ext-opcache.ini containing zend_extension=opcache no longer resolves.

Users who persisted /usr/local/etc/php/conf.d from a previous PHP 8.4 based image therefore get a PHP startup warning on every php invocation:

Warning: Failed loading Zend extension 'opcache' (tried: .../opcache.so: cannot open shared object file ...)

Because display_errors is set to STDOUT, that warning is captured into the version string the entrypoint reads for its downgrade check (installed_version / image_version). The corrupted value makes version_greater report a false downgrade, so Nextcloud refuses to start.

Fix

Suppress PHP warnings while reading the installed/image version in docker-entrypoint.sh (-d display_errors=stderr + 2>/dev/null) so a stale zend_extension=opcache directive (or any other PHP startup warning) can no longer poison the version comparison.

Verification

Reproduced the exact issue error using the published nextcloud:34-fpm image with a stale zend_extension=opcache directive in conf.d and the original entrypoint. After the fix, the entrypoint correctly proceeds to Initializing nextcloud 34.0.3 ... Upgrading nextcloud from 34.0.0.12 ... instead of blocking with the false downgrade.

The change was applied to docker-entrypoint.sh and propagated to every generated entrypoint.sh (as done by update.sh).

In PHP 8.5 the opcache extension is statically compiled into the base
image, so there is no opcache.so and the php:8.4-style
'docker-php-ext-opcache.ini' with 'zend_extension=opcache' no longer
resolves. Users who persisted /usr/local/etc/php/conf.d from a previous
PHP 8.4 based image therefore get a startup warning:

  Failed loading Zend extension 'opcache' ...

Because display_errors is set to STDOUT, that warning ends up in the
version string captured by the entrypoint for the downgrade check, which
corrupts the comparison and makes Nextcloud refuse to start with:

  Can't start Nextcloud because the version of the data (...) is higher
  than the docker image version (...) and downgrading is not supported.

Suppress PHP warnings while reading the installed/image version so a
stale opcache zend_extension directive (or any other PHP startup warning)
can no longer poison the version comparison.

See nextcloud#2595

Signed-off-by: sharyaropensource <sharyaropensource@users.noreply.github.com>
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.

PHP 8.5 Breaks Upgrading

1 participant