Skip to content

Fix CI_Cache dynamic property deprecation on PHP 8.2+ - #3472

Merged
magicbug merged 1 commit into
magicbug:devfrom
mezinster:upstream-php82-driver-deprecation
Oct 1, 2026
Merged

magicbug merged 1 commit into
magicbug:devfrom
mezinster:upstream-php82-driver-deprecation

Conversation

@mezinster

Copy link
Copy Markdown

Fixes #3146

On PHP 8.2+ every page that loads the cache driver (dashboard, logbook, etc.) shows:

Severity: 8192
Message: Creation of dynamic property CI_Cache::$file is deprecated
Filename: libraries/Driver.php
Line Number: 188

(and the same for CI_Cache::$dummy). In development mode this is printed into the page, and as reported in #3146 it can also end up inside JSON responses and break saving QSOs.

CI_Driver_Library::load_driver() stores each loaded driver in an undeclared property. This adds #[AllowDynamicProperties] to CI_Driver_Library and CI_Driver, the same fix already applied to CI_Controller, CI_Loader, CI_DB_driver and CI_Profiler. CI_Cache inherits the attribute from CI_Driver_Library.

The attribute is a no-op comment on PHP 7.x, so nothing changes for older installs.

Testing

  • php -l system/libraries/Driver.php on PHP 7.4.33 and 8.2.34
  • Reproduction script (subclass of CI_Driver_Library assigning $file / $dummy, as load_driver() does):
    • PHP 8.2, before: both deprecations emitted
    • PHP 8.2, after: none
    • PHP 7.4: clean before and after
  • Running on a PHP 8.2 + Apache deployment: dashboard and logbook render without the notices

CI_Driver_Library loads drivers into undeclared properties
(CI_Cache::$file, CI_Cache::$dummy), which PHP 8.2+ reports as
"Creation of dynamic property ... is deprecated". Mark CI_Driver_Library
and CI_Driver with #[AllowDynamicProperties], as already done for
CI_Controller and CI_Loader. On PHP 7.x the attribute is parsed as a
comment, and subclasses such as CI_Cache inherit it.

Fixes magicbug#3146

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused change correctly resolves the reported deprecations without affecting supported older PHP versions.

Review effort: Balanced
Findings: None

What changed in this PR

Adds PHP 8.2+ compatibility for CodeIgniter driver classes, preventing dynamic-property deprecation notices.

Changes:

  • Adds #[AllowDynamicProperties] to both driver base classes.
  • Preserves PHP 7.x compatibility.
File Description
system/​libraries/​Driver.php Allows intentional runtime driver properties.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@magicbug
magicbug merged commit 7fae553 into magicbug:dev Oct 1, 2026
1 check failed
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.

3 participants