mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-27 00:25:50 +03:00
[PR #495] [CLOSED] Fix spurious E_WARNING being emitted from date_default_timezone_get(). #1185
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#1185
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Seldaek/monolog/pull/495
Author: @jchesterpivotal
Created: 1/14/2015
Status: ❌ Closed
Base:
master← Head:fix-datetime-warning📝 Commits (1)
f0ded6bFix spurious E_WARNING being emitted from date_default_timezone_get().📊 Changes
1 file changed (+4 additions, -0 deletions)
View changed files
📝
src/Monolog/Logger.php(+4 -0)📄 Description
Other packages relying on Monolog will sometimes interpret E_WARNINGs as exceptions, causing
them to fail. The usual advice is to edit php.ini to set the date.timezone setting. But this
approach requires turning every development workstation into a snowflake. Instead, we follow
the lead of other projects and introduce this snippet to modify the default PHP behaviour.
Normally, we would provide a test case to demonstrate that the E_WARNING is no longer
emitted from Monolog. However we could not find a way to test this behaviour. To start with,
multiple sites in the test code (both PHPUnit and the Monolog bootstrap.php) will either
use ini_set() on date.timezone, or date_default_timezone_set(), to set the timezone to UTC.
Once this is done, the E_WARNING is never emitted again. Then, if we try to use ini_set()
or ini_restore() in the test, PHP either rejects (ini_set) or ignores (ini_restore) our
attempt to recreate the default conditions which lead to this problem. There may be a way
to test this, but we are not aware of one.
The snippet included here, or similar snippets, appears widely in the PHP universe. An
identical snippet appears in Composer[1] and semantically identical code has been baked
into phpBB[2] and Mediawiki[3], amongst others that we found while searching.
In an ideal world, the PHP interpreter would stop emitting the E_WARNING. UTC is a sane
default value for timezone settings, and users who required a different setting would
be motivated to find the mechanism for changing it, leaving the common case unpunished.
However, it seems that this is unlikely to occur[4]. Hence, this patch is required to
work around the shortcomings of PHP.
[1]
github.com/composer/composer@e5ecad7eeb[2] https://tracker.phpbb.com/browse/PHPBB3-7729
[3] http://git.wikimedia.org/commit/mediawiki%2Fcore.git/8e41f42b67cec4a6256080aea8a89c9e5b0ceb05
[4] http://www.serverphorums.com/read.php?7,712151
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.