Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39322 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90595 invoked from network); 25 Jul 2008 11:12:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2008 11:12:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.94.239.7 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.94.239.7 mail.jdi-ict.nl Linux 2.6 Received: from [82.94.239.7] ([82.94.239.7:38307] helo=mail.jdi-ict.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/37-22699-F05B9884 for ; Fri, 25 Jul 2008 07:12:15 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.jdi-ict.nl (8.13.7/8.12.11) with ESMTP id m6PBCBMP020513; Fri, 25 Jul 2008 13:12:11 +0200 Date: Fri, 25 Jul 2008 13:12:11 +0200 (CEST) X-X-Sender: derick@kossu.ez.no To: Jack Steadman cc: Christian Seiler , PHP Developers Mailing List In-Reply-To: <7AFF263C3DBE2549899F71BB925794FF0492A865@sullivan.smartertravelmedia.com> Message-ID: References: <7AFF263C3DBE2549899F71BB925794FF0492A863@sullivan.smartertravelmedia.com> <48884251.1020300@gmx.net> <7AFF263C3DBE2549899F71BB925794FF0492A865@sullivan.smartertravelmedia.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Subject: RE: [PHP-DEV] question about backward-compatibility break/bug in php 5.2.6 From: derick@php.net (Derick Rethans) On Thu, 24 Jul 2008, Jack Steadman wrote: > Thank you for taking the time to explain this to me. A couple more > points below: > > > strtotime() has always accepted month and day numbers 0 in order to > > express "last month of the previos year" and "last day of the previous > > month". Take: > > So my biggest issue with this is that it's exception-case behavior, > treating truly invalid dates as valid dates for no obvious reason. Who > needs this functionality? Why is it even a good idea? It's nice to find the last day of next month. > A close second is that this behavior is completely undocumented. > http://us.php.net/strtotime states that the time argument to strtotime > is "The string to parse, according to the GNU > Date Input Formats > syntax" and that false is returned on failure. GNU date formats do NOT > allow for zero months and days (see > http://www.gnu.org/software/tar/manual/html_node/Calendar-date-items.htm > l#SEC116). No official mention is made of the exception case that you > describe. The closest the docs come is a user comment on the strtotime > page from June 19 of this year (perhaps someone who upgraded to 5.2.6 > and found this behavior for the first time?) warning other users that > 2008-00-14 is interpreted as 2007-12-14. Yes, the documentation is broken. I'm working on fixing that. > This is not actually the case. Take one of our machines (first part of > php -i included here): > This 64-bit machine is running 5.2.5 and returns false on the all-zero > datetime string. It was upgraded last week to 5.2.6 and started > returning the large negative integer. > *Something* changed in date handling between 5.2.5 and 5.2.6. Whether > you perpetuate the exception case or not, it *is* a regression. Yes, because there was a regression in 5.2.[45]: php-5.2.6$ sapi/cli/php -n -r 'var_dump( strtotime( "0000-00-00 00:00" ) );' int(-62169987600) php-5.2.5$ sapi/cli/php -n -r 'var_dump( strtotime( "0000-00-00 00:00" ) );' bool(false) php-5.2.4$ sapi/cli/php -n -r 'var_dump( strtotime( "0000-00-00 00:00" ) );' bool(false) even in PHP 5.1 it doesn't return false (although it's incorrect): $ php-5.1dev -n -r 'var_dump( strtotime( "0000-00-00 00:00" ) );' int(943916400) and *even* on 4.3.9: $ php-4.3.9 -n -r 'var_dump( strtotime( "0000-00-00 00:00" ) );' int(943916400) regards, Derick -- HEAD before 5_3!: http://tinyurl.com/6d2esb http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org