PHP 8.4 and 8.5 compatibility#62
Merged
Merged
Conversation
This was referenced Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #61 (closed due to branch protection preventing updates).
Summary
This PR adds forward-compatibility for PHP 8.4 and PHP 8.5 while keeping PHP 8.2/8.3 support.
The last PHP 8.4 pass (#34) landed in 1.9.0, but a handful of spots still rely on silent null/false coercion that becomes a hard error on PHP 8.5 (where several long-standing deprecations are being promoted to TypeErrors, e.g. passing null to internal string functions, or passing a non-parseable string to
DateTime::modify()).cc @rhoerr @dadolun95 @SamueleMartini — happy to iterate if you want to tag this as 2.1.2 after merge.
Fixes
Plugin/Adminhtml{Category,Cms,Product}BeforeSavePlugin: cast the return value ofpreg_replace()to string beforestrtolower().preg_replacecan returnnullon failure, andstrtolower(null)is aTypeErroron PHP 8.5.Helper/Service::encodePageBuilderHtmlBox: castDOMDocument::saveHTML()results to string before feeding them tohtml_entity_decode()/ string concatenation.saveHTML()can returnfalse; PHP 8.5 enforces thestringparameter ofhtml_entity_decodestrictly.Helper/ModuleConfig::getTranslationExpirationDate: cast the retranslation-period scope value to int before building theDateTime::modify()expression. Previously an unset/empty config produced- days, which becomes aDateMalformedStringExceptionon PHP 8.5.Setup/Patch/Data/MigrateConfigPaths: cast the legacy scope value to string before re-encrypting, sinceEncryptorInterface::encrypt()now requires a strict string on PHP 8.5.string/intbefore using as array key to avoid PHP 8.5 null array key deprecation (follow-up to PHP 8.4 and 8.5 compatibility #61 feedback on PHP 8.4 and 8.5 compatibility mage-os-lab/module-widgetkit#13).composer.json: widen the PHP constraint to>=8.2 <8.6so Composer resolves cleanly on PHP 8.4 and 8.5.No behavior change on PHP 8.2/8.3 — all casts are no-ops on valid input.
Suggested tag
2.1.2(patch — backwards compatible bug fixes only).Test plan
php -lon all changed filesurl_key/identifieron PHP 8.5