Appearance
<div style="display: none;" hidden="true" aria-hidden="true">Are you an LLM? You can read better optimized documentation at /guides/Php85Upgrade.md for this page in Markdown format</div>
PHP 8.5 Upgrade Guide
This guide shows how to move a shop (a "tenant") from PHP 8.1 to PHP 8.5. It covers Kubernetes and Plesk, and client forks.
1. What changes and who must act
- The PHP 8.5 code work is done. The runtime images for PHP 8.5 are published.
- Nothing switches by itself. When you merge a release, your PHP version stays the same.
- Each tenant switches in its own time:
- Kubernetes tenants switch through the
ecnv4_manifestsrepo (done by its maintainers). - Plesk tenants switch in Plesk (done by the server admin).
- Kubernetes tenants switch through the
- PHP 8.1 is still supported. Dropping it will be announced in a later release.
2. Before you start
First safe version
The first app version that is safe on PHP 8.5 is 4.130.0 (or any later release). Its changelog says it is the first release safe on PHP 8.5.
These are not safe: 4.129.0 itself, any 4.129.x hotfix, and client builds based on them (for example 4.129.0.x-<client>). The PHP 8.5 fixes (#981, #1016) are not in them. Do not switch to PHP 8.5 on older code.
One-time logout
When you switch, every logged-in user (shop and admin) is logged out once, and loses the session cart. The reason: session cookies made on PHP 8.1 no longer match the format that PHP 8.5 expects (see #978).
- During a rolling deploy, 8.1 and 8.5 pods run side by side. A user can be logged out more than once.
- Rolling back to 8.1 logs everyone out once more.
- Switch at a quiet time and roll out quickly.
Test the payment gateways first
The payment gateways (Stripe, PayPal, Klarna, Viva, Greek banks) and their server-to-server callbacks were not run on PHP 8.5. Before you switch a live shop, test the gateways that the tenant uses in their sandbox or staging. New clients do this anyway before they go live.
3. Kubernetes steps
Do these in the tenant folder of ecnv4_manifests. Do staging first where it exists (for example seajets, seajets-santorini and wecare).
Step 1. Move the app code first
Change the adveshop4-app_bootstrap tag to the first safe version (or later) before the runtime. Some tenants still run old code (4.118 to 4.122). That code breaks if only the runtime changes.
Step 2. Clean the php.ini ConfigMaps
The php.ini lives in the ConfigMaps. For the web and admin pods, most tenants use app.yaml. The tenants seajets and seajets-santorini have no app.yaml with ini lines. For them the web and admin ini is in app-admin.yaml (their app-front.yaml has no ini lines). The cron ini is app-cron.yaml for all tenants except WeCare. (WeCare has both inis in base/app.yaml.)
Do Step 2 and Step 3 in the same deploy. This applies to the production switch. For a tenant without staging, it is the only switch. Do not apply Step 2 alone. On PHP 8.1, OPcache is loaded only by the zend_extension=opcache line. If you remove it before the image switch, the shop runs on 8.1 without OPcache. If you remove the session.sid_* lines early, the session ids change and users are logged out before the switch.
If staging shares base/ with production, read "Staging first, when staging shares base/ with production" below before you touch these lines.
Remove these lines:
ini
session.sid_length = 26
session.sid_bits_per_character = 5
zend_extension=opcache(The cron inis have only the two session.sid_* lines. They never had zend_extension=opcache.)
session.sid_lengthandsession.sid_bits_per_characterare deprecated since PHP 8.4 (so also on 8.5).zend_extension=opcachemust go. OPcache is built into PHP 8.5. With the line left in, every PHP start prints "Failed loading Zend extension 'opcache'".- Keep the other
opcache.*settings. Preload and JIT work on PHP 8.5.
Step 3. Change the image tags
In the tenant kustomization.yaml, in the images: block, change the tag of adveshop4-php_fpm and adveshop4-php_cli:
yaml
images:
- name: ecommercen/adveshop4-php_fpm
newTag: 1.0.0-8.5.12 # was 1.0.0-8.1.34
- name: ecommercen/adveshop4-php_cli
newTag: 1.0.0-8.5.12 # was 1.0.0-8.1.34These are two entries: ecommercen/adveshop4-php_fpm and ecommercen/adveshop4-php_cli. Together they cover the web, cron, cron-runner and admin pods. Check the exact name: lines in your own file; keep them as they are and change only the tag.
Where the entries live is different per tenant:
base/kustomization.yamlfor the realm-1-* tenants and for seajets / seajets-santorini production.prod/kustomization.yamlfor wecare production.stg/kustomization.yamlfor the staging overlays.
Do not switch or roll back the PHP version from ecn-console alone. The ecn-console app config shows these two versions. A change from there only changes the images: block. It does not change the php.ini ConfigMaps. The ini lines must change in the same deploy. On a rollback, a console-only tag change leaves PHP 8.1 without OPcache and with changed session ids. The one exception is the staging step below for tenants whose staging shares base/: there, changing only the tags (for example from ecn-console) is fine.
Staging first, when staging shares base/ with production
For seajets, seajets-santorini and wecare, the php.ini ConfigMaps are in the shared base/ folder. Both prod and stg import it (resources: - ../base). Only the image tags are separate (stg/kustomization.yaml, images:).
So if you remove the ini lines in base/ "for staging", you change production too, and at once. These Deployments have the Reloader annotation (reloader.stakater.com/auto: "true"), so a ConfigMap change restarts every prod web and admin pod straight away (CronJob pods pick it up at their next run). All prod pods then run on PHP 8.1 without OPcache and with different session-id settings, and every user is logged out at once.
Do this instead:
- For the staging run, switch only the image tags in
stg/kustomization.yamlto1.0.0-8.5.12. Do not edit the php.ini lines inbase/yet. - On 8.5 the leftover lines are harmless.
zend_extension=opcacheonly prints "Failed loading Zend extension 'opcache'" (OPcache is built in and stays on). Thesession.sid_*lines only give deprecation notices. - Staging still shows the one-time logout. The session-id format differs between 8.1 and 8.5 either way.
- For production, remove the three lines in
base/and switch the production tags in the same deploy (Step 2 and Step 3 together). That deploy also changes staging's ini, and Reloader restarts the staging web and admin pods straight away. With the cleaned ini, the session-id format changes again (26 chars at 5 bits becomes 32 chars at 4 bits). So staging users are logged out once more.
The staging run tests the 8.5 image, not the final cleaned ini.
The files are seajets/app/base/app-admin.yaml and app-cron.yaml, seajets-santorini/app/base/app-admin.yaml and app-cron.yaml, and wecare/adveshop4/base/app.yaml.
WeCare's API (wecare/adveshop4/base/app-api.yaml) runs a separate image (ecommercen/wecare-api-php_fpm). This guide does not cover it. Switching WeCare's adveshop4 images does not move the API. realm-1-pharmacydiscount also runs a separate API image (ecommercen/pharmacydiscount-api-php_fpm, today 1.0.0-8.2.35, in its base/kustomization.yaml) that this guide does not cover.
4. Plesk steps
These are done by the server admin.
Update the code to the first safe version (or later).
Install PHP 8.5 with the same extensions as on PHP 8.1. Compare the output of
php -mon both. You need at least:- redis 6.3.0 or newer
- igbinary 3.2.17RC1 (a release candidate; no stable release supports PHP 8.5 yet)
- apcu 5.1.28
- sqlsrv and pdo_sqlsrv 5.13 or newer, if the tenant uses an MSSQL ERP
- the usual ones: bcmath, calendar, curl, dom, exif, FFI, fileinfo, gd, iconv, mbstring, mysqli, pdo_mysql, soap, xml, xmlreader, xmlwriter, zip
In the domain's PHP settings, make sure these are not set:
session.sid_length,session.sid_bits_per_character. Also make surezend_extension=opcacheis not loaded.Switch the domain, its cron jobs, and the PHP used for
composer, to PHP 8.5.Do Step 3 and Step 4 at the same time. In Plesk, the domain's additional PHP directives belong to the domain, not to the PHP version. If you remove the lines first, the live 8.1 site changes: every user is logged out once (CodeIgniter tops the session id up to 40 hex characters), and 8.1 may run without OPcache. Then everyone is logged out again after the switch to 8.5. If your server is set up that way, you can instead put the removals into the PHP 8.5 handler's own settings, not the domain's.
Use Composer 2.10.x. Composer 2.8.x prints PHP 8.5 deprecation notices.
Flush the app cache right after the switch. Do it the safe way (see
docs/guides/Cache.md, "Pscache Helper Functions"):- Use the app's own cache clear: the admin menu item Clear Cache (
advisable/clearcache, which runsclearCache('all')). Or clear only this tenant's Redis prefix or database. - Before you use Clear Cache on a shared Redis, check that
APP_CACHE_L2_PREFIX(or?prefix=inAPP_CACHE_L2_CONNECTION) is set to a value unique to this tenant, or that the Redis database is used only by this tenant. Otherwise it also deletes other shops' cache keys. The reason:RedisAdapter::clear()(src/Cache/Adapter/RedisAdapter.php, throughdeleteByPattern('*')) deletes every key under its prefix. That prefix is always<tenant prefix>:cache:l2:, so sessions are never touched. But with an empty tenant prefix it is justcache:l2:, which every shop on that Redis shares. - Never run
redis-cli FLUSHALL. On a shared Redis it also wipes sessions and other shops' keys. - APCu lives inside each PHP-FPM process. Restart PHP-FPM. A CLI flush does not clear it.
Why this matters: with the default setting (
serializer=autoin the Redis connection settings), the Redis serializer picks igbinary when it is loaded (code:src/Cache/Adapter/WithRedisOptionsTrait.php:20-27, default insrc/Database/Redis/RedisConnectionConfig.php). Check whether your Redis connection setsserializer=explicitly. If it pinsserializer=igbinary, the igbinary extension MUST be loaded on 8.5. Cached data written by the old setup may not be readable.- Use the app's own cache clear: the admin menu item Clear Cache (
5. Client forks
A fork's own copy of a file replaces the main repo's version. So a fix in the main repo never reaches that copy, and an upstream merge does not warn you. The fork-owned file lists are in the __Notes__ of the 4.130 changelog:
- Dynamic properties (#981, Bitbucket PR #452): the notes on
Bulker,SimpleImageandAdv_mailerdeclaring their properties. - Null array offsets (#981, Bitbucket PR #455): the notes listing the fork-owned views under
application/views/that read a nullable array key.
Before you switch, run the PHP 8.5 checks. Both tools are in the main repo's dev dependencies, so run composer install first.
On the shipped configs (they scan the whole tree):
bash
composer run rector:dry-run
composer run php-compatThese two scripts scan the whole tree (system, application, ecommercen, src, patches; see rector.php and .phpcs-compat.xml), not only application/. In a fork, act only on findings in your OWN files (the application/ and custom/ files the fork owns). Do not "fix" the main-owned folders inside the fork.
Composer's default script timeout (300 s) may stop a full-tree run. Run the tools directly instead, or set COMPOSER_PROCESS_TIMEOUT=0:
bash
php -d memory_limit=2G vendor/bin/rector process --dry-run
vendor/bin/phpcs --standard=.phpcs-compat.xmlOn custom/ (not covered by the shipped configs, so give the path):
bash
php -d memory_limit=2G vendor/bin/rector process --dry-run custom
vendor/bin/phpcs --standard=.phpcs-compat.xml customNotes:
- These commands need
rector.phpand.phpcs-compat.xmlin the fork. They arrive with the upstream merge of the release that ships them. Merge upstream first. --dry-runonly prints findings. It changes no file. Never runrector processwithout--dry-runbefore you have read the findings.- Both tools exit with a non-zero code when they find something. That is normal. Read each finding.
- Some findings are style hints, not 8.5 breaks. Example: PHPCompatibility warns about a class called
Resource("soft reserved keyword"). Judge each one.
6. Rollback
- Kubernetes: change the
adveshop4-php_fpmandadveshop4-php_clitags back to1.0.0-8.1.34. The 8.1.34 images stay published. Switching the tags is not enough. In the same deploy, also restore exactly the lines you removed in Step 2, in the same ConfigMaps. The cron ini (app-cron.yaml) never hadzend_extension=opcache; that line was only in the web and admin ini. The full set was:iniWithoutzend_extension=opcache session.sid_length = 26 session.sid_bits_per_character = 5zend_extension=opcache, PHP 8.1 runs without OPcache. It is slower and shows no error. - Plesk: switch the domain (and its cron jobs and composer) back to PHP 8.1. If you removed
session.sid_lengthandsession.sid_bits_per_characterfor 8.5, put back the values you removed (on Kubernetes they were 26 and 5; a Plesk domain may have had other values or none). Make sure OPcache is enabled again for 8.1. - Everyone is logged out once more.
7. What was verified
- The images
ecommercen/adveshop4-php_{base,cli,cli_dev,fpm,fpm_dev}at1.0.0-8.5.12are on Docker Hub. The1.0.0-8.1.34and1.0.0-8.1.32images are still there. - The 8.5 image has the same
php -mlist as the 8.1.34 image. - The PHP 8.5 fixes of #981 were checked at runtime on the local PHP 8.5 stack.
- Not tested on PHP 8.5: the payment gateways and their callbacks. Test them per tenant (see section 2).