Skip to content

fix: avoid the E_STRICT deprecation on PHP 8.4+ - #189

Open
adriandmitroca wants to merge 1 commit into
rollbar:masterfrom
adriandmitroca:fix/php84-e-strict-deprecation
Open

adriandmitroca wants to merge 1 commit into
rollbar:masterfrom
adriandmitroca:fix/php84-e-strict-deprecation

Conversation

@adriandmitroca

Copy link
Copy Markdown

Problem

On PHP 8.4 and later, every request on a site with the plugin active logs two notices:

Deprecated: Constant E_STRICT is deprecated since 8.4, the error level was removed in .../src/Plugin.php on line 233
Deprecated: Constant E_STRICT is deprecated since 8.4, the error level was removed in .../src/Settings.php on line 130

Plugin::buildIncludedErrno() and the "Logging Level" options in Settings read the E_STRICT constant. PHP 8.4 deprecated the constant itself, so just reading it raises E_DEPRECATED. With WP_DEBUG on, this adds two log lines per request; on busy sites it becomes the largest source of PHP log volume.

Fix

Add Plugin::E_STRICT = 2048 (the value of E_STRICT) and use it in both places, without reading the global constant.

  • The bitmask built by buildIncludedErrno() is identical on every supported PHP version (E_STRICT === 2048).
  • Saved settings that hold 2048 keep working, and the option keeps its label.
  • PHP has not raised E_STRICT errors since 8.0, so including the bit has no effect beyond backward compatibility.

Test

  • php -l on both changed files.
  • On PHP 8.5, the two deprecation notices no longer appear after the change. The included bitmask for each logging level is unchanged.

🤖 Generated with Claude Code

PHP 8.4 deprecated the E_STRICT constant, so reading it in buildIncludedErrno() and in the logging-level options raises an E_DEPRECATED notice on every request. Use its value (2048) through Plugin::E_STRICT instead: the bitmask and saved settings are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

1 participant