rfc:date.timezone_warning_removal

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:date.timezone_warning_removal [2015/01/27 14:39] bwoebirfc:date.timezone_warning_removal [2015/02/27 22:29] – Implemented. bwoebi
Line 1: Line 1:
 ====== PHP RFC: Remove the date.timezone warning ====== ====== PHP RFC: Remove the date.timezone warning ======
-  * Version: 1.0+  * Version: 1.2
   * Date: 2015-01-27   * Date: 2015-01-27
   * Author: Bob Weinand, bobwei9@hotmail.com   * Author: Bob Weinand, bobwei9@hotmail.com
-  * Status: Under Discussion+  * Status: Implemented
   * First Published at: https://wiki.php.net/rfc/date.timezone_warning_removal   * First Published at: https://wiki.php.net/rfc/date.timezone_warning_removal
  
 ===== Introduction ===== ===== Introduction =====
-Each time we use date() or generally functions which make use of the date.timezone ini setting, we get a warning. Even when only just trying to try something small with PHP cli involving datesespecially without a default php.ini installed, we can't just get nice output without an annoying warning. Sure, there exists "-ddate.timezone=UTC", but you usually forget to explicitly specify it and then are annoyed about it.+PHP should be usable without configuring it through either an ini file or defining settings on the command line. Currently this is not possible as the date.timezone is required to be setdespite it defaulting to the best option.
  
-Generally warning should be there there to guide the user when developingJust like superfluous warnings confuse him.+"date.timezone" is the only setting that is required to be setEvery other setting, including those that have security implications default to sensible values silently; defaulting to sensible values does not appear to cause any problem for users
  
-ThusI'd like to remove this warning in favor of a better user experience.+The error message becomes entirely tedious when working with anything other than a single installed version of PHP. 
 + 
 +For example when you want to run the unit tests for a library against all the different versions of PHP that library supportsyou should be able to do so by downloading each of the PHP versions you want to test against, and invoking the PHP executables from the download location, rather than having to install it first
  
 ===== Proposal ===== ===== Proposal =====
-Removing the date.timezone warning in case the date.timezone ini setting is empty.+The current behaviour when the data.timezone ini entry is not set is to:
  
-The date.timezone warning has this text:+  * Default to UTC. 
 +  * Give a warning message.
  
-It is not safe to rely on the system's timezone settingsYou are *required* to use the date.timezone setting or the date_default_timezone_set() functionIn case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.+The proposal is just to remove the warning messageThe behaviour of setting the timezone to be UTC would not be changedThis will allow people to run PHP without an ini file without having error messages.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
Line 25: Line 28:
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
 If the date.timezone ini setting is set but invalid, a warning is still thrown. If the date.timezone ini setting is set but invalid, a warning is still thrown.
-The default is and remains UTC.+ 
 +===== Feedback ===== 
 +==== "Won't this make life more difficult for end users?" ==== 
 +No. For users who install PHP through a distribution, the ini file is created by the package maintainer. They should set it to the systems timezone. (Some don't, but that is the fault of the distributions.) 
 + 
 +For end users who compile from source they can either modify the ini file that is used by PHP in the compile step or they could add it themselves when PHP is built e.g. For Debian they could easily stick the following in a post-install hook to fix it: 
 + 
 +    echo 'date.timezone='`cat /etc/timezone` > /etc/php/config.d/date.ini 
 +     
 +People who are compiling PHP from source are perfectly capable of setting all ini settings that need to be set. 
 + 
 +The only people who this RFC will affect are: 
 + 
 +  * Those who use multiple versions of PHP or otherwise use PHP without going through the install process. This RFC will be beneficial to these users. 
 +  * People who have accidentally deleted their ini files from their production system. These users have bigger issues than this RFC can address. 
 + 
 +Still, it is weird, to have that one setting emit a warning, but other much more important settings don't. The ini settings have defaults and they should be used. 
 + 
 +==== "Users are idiots and can't be trusted" ==== 
 +Well, yes. But there are many things that must be set in an ini file for PHP to be usable in a production environment. The person installing PHP needs to be capable of setting all of these. The timezone setting is not the most important setting that needs to be set so it's not good that PHP gives a warning message when it is not set. 
 + 
 +==== "Can't you just define the timezone in the command line? Like: `php -d date.timezone=UTC foo.php`" ==== 
 +This is a painful hack. For people who spend a significant amount of time either developing PHP, PHP extensions or testing userland code against multiple PHP versions, they should be able to run PHP code without getting slapped for the temerity of not using an ini file and without being forced to set an ini setting to the same default value it is going to use anyway. 
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
-Remove this warning (50%+1 vote): +Remove this warning (50%+1 vote) - Vote began 2015-02-16 and ended 2015-02-24. 
-  * Yes + 
-  * No+<doodle title="Should the warning about a not set date.timezone ini setting be removed in master?" auth="bwoebi" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
 ===== Patch ===== ===== Patch =====
Line 41: Line 70:
   * https://bugs.php.net/bug.php?id=53473   * https://bugs.php.net/bug.php?id=53473
   * https://bugs.php.net/bug.php?id=35481   * https://bugs.php.net/bug.php?id=35481
 +
 +===== Versions =====
 +
 +  * 1.0: Initial RFC (2015-01-27)
 +  * 1.1: More neutral wording, discussion of feedback (2015-02-15)
 +  * 1.2: Put into vote (2015-02-16)
rfc/date.timezone_warning_removal.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1