Skip to content

[zend-log] log deprecations with DEBUG priority, as documented - #240

Open
falkenhawk wants to merge 2 commits into
masterfrom
fix-log-error-handler-map
Open

falkenhawk wants to merge 2 commits into
masterfrom
fix-log-error-handler-map

Conversation

@falkenhawk

@falkenhawk falkenhawk commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

followup to #205

Zend_Log::registerErrorHandler() should log E_DEPRECATED, E_USER_DEPRECATED and E_STRICT with the DEBUG priority, as its docblock says.
They are logged as INFO instead:

$writer = new Zend_Log_Writer_Mock();
$logger = new Zend_Log($writer);
$logger->registerErrorHandler();
trigger_error('old api', E_USER_DEPRECATED);
echo $writer->events[0]['priorityName']; // INFO, documented: DEBUG

The priority map is keyed by error level, but these levels were added with their names as strings ('E_DEPRECATED').
The error handler looks the priority up by the error level number, finds nothing and falls back to INFO, the priority for unknown errors.
This has been there since registerErrorHandler() was added (ZF-9192, zendframework/zf1).
#205 moved E_STRICT into the same pattern, so since 1.16.0 E_STRICT is logged as INFO on php 7 too.

Fix

The map uses the constants as keys again.
E_STRICT is only added below php 8.4, where using the constant is not deprecated. php 8 never raises E_STRICT anyway.

The fix is carried over from zf1-future, Shardj/zf1-future#485.

Behavior change

Deprecations are now logged with DEBUG (7) instead of INFO (6), as documented.
A writer that only logs INFO and above, e.g. with Zend_Log_Filter_Priority(Zend_Log::INFO), no longer writes them.
On php 8 deprecations can be a large part of what the error handler logs, so this should be mentioned in the changelog.

Ported from a private repository, based on work by @marcing.

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