Skip to content

Fix PHP 8.5 deprecations in backend, CMS and system modules - #1609

Merged
LukeTowers merged 3 commits into
developfrom
fix/php85-null-deprecations
Dec 1, 2026
Merged

LukeTowers merged 3 commits into
developfrom
fix/php85-null-deprecations

Conversation

@LukeTowers

@LukeTowers LukeTowers commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Fixes PHP 8.5 deprecations that fire on ordinary requests. Found on a production site running PHP 8.5, then by running the full test suite on PHP 8.5 with every deprecation logged at its call site (1243 tests pass).

Each null is treated the way it already was (an empty string, or no match), so behaviour is unchanged.

Null passed to string functions / used as an array offset

  • NavigationManager::getContextOwner(): null array offset when no context owner is set
  • FormField::evalConfig(): strtolower(null) when a field has no type (overlaps with the guard in Fix deprecation notices in the backend module #1490)
  • RelationController::relationRender(): strtolower(null) when no section option is passed
  • Lists::evalTextTypeValue(): htmlentities(null) for empty column values
  • FormController create/update/preview: strlen(null) when no context is passed
  • PluginManager::getActiveReplacementMap(): null array offset for every plugin that doesn't replace another (Updates page, UpdateManager)
  • Backend Controller::execAjaxHandlers(): trim(null) on every AJAX request without X_WINTER_REQUEST_PARTIALS
  • Repeater::processItems(): starts_with(null) on non-AJAX renders
  • MediaManager::prepareVars(): strlen(null) with no search term
  • MyAccount::update_onSave(): strlen(null) when no new password is posted
  • MailSetting::initSettingsData(): strlen(null) with no SMTP username (the default)
  • CMS Index controller: pathinfo(null) for a new template without a file name
  • CmsCompoundObject::beforeSave(): str_replace() on a null original code
  • ComponentManager::makeComponent(): class_exists(null) for soft components that aren't installed
  • Theme::getActiveThemeCode(): strlen(null) when no theme is active
  • PackageJson: File::exists(null) when constructed without a path

Removed or replaced APIs

Since System\ServiceProvider::registerLogging() writes every log message to system_event_logs, each of these also cost a database insert per occurrence.

Not fixed here: deprecations inside Laravel 9 vendor code (InteractsWithIO null verbosity offset, str_getcsv() without $escape in ValidationRuleParser, setAccessible() in HigherOrderTapProxy) and in winter/laravel-config-writer (ArrayPrinter.php:286 null offset, implicitly nullable parameters).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of empty, missing, or non-string values across forms, relation rendering, media search, navigation, and other backend and CMS features.
    • Fixed plugin replacement lookup when no active replacement is configured.
    • Improved MySQL SSL configuration compatibility with newer PHP versions.
    • Updated handling of optional package paths and mail settings to avoid errors with missing or non-string values.

…igation code

Running on PHP 8.5 logs deprecations from these spots on ordinary backend requests:

- NavigationManager::getContextOwner(): null used as an array offset when no context owner is set
- FormField::evalConfig(): strtolower(null) when a field has no type
- RelationController::relationRender(): strtolower(null) when no section option is passed
- Lists::evalTextTypeValue(): htmlentities(null) for empty column values
- FormController create/update/preview: strlen(null) when no context is passed

Each now treats null the way it was already treated before (an empty string, or no owner).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Backend, CMS, and system methods now cast values before string operations or check for null values before lookup or file checks. getContextOwner() now returns null when no context owner is set. The MySQL SSL CA option uses a PHP-version-specific constant. Reflection-based test helpers no longer call setAccessible(true).

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: Minimal · up to ac93f

This change silences PHP 8.5 null deprecations in backend, CMS and system code while keeping existing behavior, and the checked paths show no new failure. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: PHP 8.5 deprecation fixes across the backend, CMS and system modules. The raw summary and PR objectives confirm that most edits cast values to strings or guard nulls, …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: PHP 8.5 deprecation fixes across the backend, CMS and system modules. The raw summary and PR objectives confirm that most edits cast values to strings or guard nulls, and that many test helpers drop setAccessible(true) calls. The title is specific enough to identify the primary change, though it does not mention the reflection cleanup in tests or the MySQL SSL constant change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0e37cd46-d18b-43ed-ad96-d815262c4b62
Commits

Reviewing files that changed from the base of the PR and between 6bc193c and ac93fac.

Files selected for processing: 23

  • config/database.php
  • modules/backend/classes/Controller.php
  • modules/backend/controllers/MyAccount.php
  • modules/backend/formwidgets/Repeater.php
  • modules/backend/tests/behaviors/RelationControllerScopingTest.php
  • modules/backend/tests/classes/BackendControllerRoutingTest.php
  • modules/backend/tests/classes/HandlerDispatchSecurityTest.php
  • modules/backend/tests/widgets/ListsSortableTest.php
  • modules/backend/tests/widgets/ReportContainerSecurityTest.php
  • modules/backend/widgets/MediaManager.php
  • modules/cms/classes/CmsCompoundObject.php
  • modules/cms/classes/ComponentManager.php
  • modules/cms/classes/Theme.php
  • modules/cms/controllers/Index.php
  • modules/cms/tests/classes/CodeParserTest.php
  • modules/cms/tests/classes/RouterTest.php
  • modules/system/classes/PluginManager.php
  • modules/system/classes/asset/PackageJson.php
  • modules/system/models/MailSetting.php
  • modules/system/tests/bootstrap/TestCase.php
  • modules/system/tests/classes/FileManifestTest.php
  • modules/system/tests/controllers/MailBrandSettingsTest.php
  • modules/system/tests/controllers/SettingsSecurityTest.php
Files with no reviewable changes: 11

  • modules/backend/tests/behaviors/RelationControllerScopingTest.php
  • modules/backend/tests/classes/BackendControllerRoutingTest.php
  • modules/backend/tests/classes/HandlerDispatchSecurityTest.php
  • modules/backend/tests/widgets/ListsSortableTest.php
  • modules/backend/tests/widgets/ReportContainerSecurityTest.php
  • modules/cms/tests/classes/CodeParserTest.php
  • modules/cms/tests/classes/RouterTest.php
  • modules/system/tests/bootstrap/TestCase.php
  • modules/system/tests/classes/FileManifestTest.php
  • modules/system/tests/controllers/MailBrandSettingsTest.php
  • modules/system/tests/controllers/SettingsSecurityTest.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

LukeTowers and others added 2 commits December 1, 2026 12:30
- config/database.php: PDO::MYSQL_ATTR_SSL_CA is deprecated in PHP 8.5 and was logged on every request using the mysql connection. Use Pdo\Mysql::ATTR_SSL_CA on PHP 8.5+, the same check the Laravel skeleton uses.
- PluginManager::getActiveReplacementMap(): null used as an array offset for any plugin that doesn't replace another (hit by the Updates page and UpdateManager for every plugin).
- Backend Controller::execAjaxHandlers(): trim(null) on every backend AJAX request without an X_WINTER_REQUEST_PARTIALS header.
- Repeater::processItems(): starts_with(null) on non-AJAX requests, where there is no AJAX handler.
- MediaManager::prepareVars(): strlen(null) when no search term is set.
- MyAccount::update_onSave(): strlen(null) when no new password is posted.
- MailSetting::initSettingsData(): strlen(null) when no SMTP username is configured.
- CMS Index controller: pathinfo(null) for a new template without a file name.
- CmsCompoundObject::beforeSave(): str_replace() on a null original code value when creating a template with code.
- ComponentManager::makeComponent(): class_exists(null) for soft components that aren't installed.
- Theme::getActiveThemeCode(): strlen(null) when no theme is active.
- PackageJson: File::exists(null) when constructed without a path.

Each null is treated as before (an empty string, or no match).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…m tests

setAccessible() has had no effect since PHP 8.1 (the minimum supported version) and is deprecated in PHP 8.5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukeTowers LukeTowers changed the title Fix PHP 8.5 null deprecations in backend form, list, relation and navigation code Fix PHP 8.5 deprecations in backend, CMS and system modules Dec 1, 2026
@LukeTowers
LukeTowers merged commit e7dab17 into develop Dec 1, 2026
16 checks passed
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