Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Richard Quadling
On 17 June 2011 00:51, Stas Malyshev smalys...@sugarcrm.com wrote:
 Hi!

 I've been looking into various tests and discovered something strange in
 date_diff. Example code:

 ?php
 $start = new DateTime('2010-10-04 02:18:48 EDT');
 $end   = new DateTime('2010-11-06 18:38:28 EDT');
 $int = $start-diff($end);
 var_dump($start);

 As a result of this I'm getting this:

 object(DateTime)#1 (3) {
  [date]=
  string(19) 2010-10-04 06:18:48
  [timezone_type]=
  int(2)
  [timezone]=
  string(3) EDT
 }

 As you can see, the date in $start changed, even though it shouldn't happen.
 Looks like it's because of timelib_diff() which has this:

    timelib_apply_localtime(one, 0);
    timelib_apply_localtime(two, 0);

 which converts times in diff arguments to localtime. It then does:

    timelib_apply_localtime(one, 1);
    timelib_apply_localtime(two, 1);

 which is supposed to convert them back, but in fact it does not, since first
 conversion seems to have killed TZ information. I'd propose to fix it by
 making time_diff operate on copies of one and two instead of real
 structures, but maybe somebody has a better idea?


Just ran Stas' script against a lot of 5.3's.

V5.3.0alpha2 :   string(19) 2010-10-04 06:18:48
V5.3.0alpha3 :   string(19) 2010-10-04 06:18:48
V5.3.0beta1 :   string(19) 2010-10-04 06:18:48
V5.3.0RC2 :   string(19) 2010-10-04 06:18:48
V5.3.0RC3 :   string(19) 2010-10-04 06:18:48
V5.3.0RC4 :   string(19) 2010-10-04 06:18:48
V5.3.0 :   string(19) 2010-10-04 06:18:48
V5.3.1RC1 :   string(19) 2010-10-04 06:18:48
V5.3.1RC2 :   string(19) 2010-10-04 06:18:48
V5.3.1RC3 :   string(19) 2010-10-04 06:18:48
V5.3.1RC4 :   string(19) 2010-10-04 06:18:48
V5.3.1 :   string(19) 2010-10-04 06:18:48
V5.3.2RC1 :   string(19) 2010-10-04 06:18:48
V5.3.2RC2 :   string(19) 2010-10-04 06:18:48
V5.3.2RC3 :   string(19) 2010-10-04 06:18:48
V5.3.2 :   string(19) 2010-10-04 06:18:48
V5.3.3RC1 :   string(19) 2010-10-04 06:18:48
V5.3.3RC2 :   string(19) 2010-10-04 06:18:48
V5.3.3RC3 :   string(19) 2010-10-04 06:18:48
V5.3.3 :   string(19) 2010-10-04 06:18:48
V5.3.4RC1 :   string(19) 2010-10-04 06:18:48
V5.3.4RC2 :   string(19) 2010-10-04 06:18:48
V5.3.4 :   string(19) 2010-10-04 06:18:48
V5.3.5 :   string(19) 2010-10-04 06:18:48
V5.3.6RC1 :   string(19) 2010-10-04 06:18:48
V5.3.6RC2 :   string(19) 2010-10-04 06:18:48
V5.3.6RC3 :   string(19) 2010-10-04 06:18:48
V5.3.6 :   string(19) 2010-10-04 06:18:48


Even though the behaviour is wrong, it is consistent.

There are no user notes commenting on this issue in the documentation.

Can't check the bug base at the moment due to it being down.

If either of the dates use a TLA timezone (EDT, PST, GMT), rather than
the long name (Europe/London, Indian/Kerguelen,
America/Kentucky/Louisville), then that date is altered.

Richard.

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Derick Rethans
On Fri, 17 Jun 2011, Richard Quadling wrote:

 On 17 June 2011 00:51, Stas Malyshev smalys...@sugarcrm.com wrote:
 
  As you can see, the date in $start changed, even though it shouldn't happen.
  Looks like it's because of timelib_diff() which has this:
 
     timelib_apply_localtime(one, 0);
     timelib_apply_localtime(two, 0);
 
  which converts times in diff arguments to localtime. It then does:
 
     timelib_apply_localtime(one, 1);
     timelib_apply_localtime(two, 1);
 
  which is supposed to convert them back, but in fact it does not, since first
  conversion seems to have killed TZ information. I'd propose to fix it by
  making time_diff operate on copies of one and two instead of real
  structures, but maybe somebody has a better idea?

Well, we need to check on why the TZ information got killed actually. As 
that's not supposed to happen. I see why this happens in the library, 
let me think of a way on how to fix this in a clean way.

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Stas Malyshev

Hi!


If either of the dates use a TLA timezone (EDT, PST, GMT), rather than
the long name (Europe/London, Indian/Kerguelen,
America/Kentucky/Louisville), then that date is altered.


Yes, this seems to be because TLA ones rely on -z and -dst which get 
reset in timelib_unixtime2gmt() while other one relies on tzinfo which 
is kept intact.

--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Derick Rethans
On Fri, 17 Jun 2011, Stas Malyshev wrote:

  If either of the dates use a TLA timezone (EDT, PST, GMT), rather 
  than the long name (Europe/London, Indian/Kerguelen, 
  America/Kentucky/Louisville), then that date is altered.
 
 Yes, this seems to be because TLA ones rely on -z and -dst which get 
 reset in timelib_unixtime2gmt() while other one relies on tzinfo which 
 is kept intact.

Yup. I'm fixing it right now.

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Derick Rethans
On Fri, 17 Jun 2011, Derick Rethans wrote:

 On Fri, 17 Jun 2011, Stas Malyshev wrote:
 
   If either of the dates use a TLA timezone (EDT, PST, GMT), rather 
   than the long name (Europe/London, Indian/Kerguelen, 
   America/Kentucky/Louisville), then that date is altered.
  
  Yes, this seems to be because TLA ones rely on -z and -dst which get 
  reset in timelib_unixtime2gmt() while other one relies on tzinfo which 
  is kept intact.
 
 Yup. I'm fixing it right now.

Done... I had to do it by making a backup for now. It should be looked 
at again though, and I've added that to my (long) todo list.

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] PHP patches

2011-06-17 Thread Robert Eisele
Hi,

my name is Robert Eisele. I'm new to this mailing list, but the one or the
other might have seen
something from me. I publish some open source stuff on my blog www.xarg.org,
where I recently
published my PHP fork, too. To avoid license bashing, it's not a fork at
all and I don't want to
manage something like this for myself, but rather a collection of patches +
a proof of concept,
with some new things and ideas that could get implemented into the main tree
of PHP.

There were some constructive discussions on hackernews and my blog, too:

http://www.xarg.org/2011/06/php-hacking/
http://news.ycombinator.com/item?id=2640756

I didn't follow any discussion on PHP internals. It seems, many people
understand and agree the
changes I made. I've also realized that some changes are still proposed and
maybe already implemented.

I'd like to contribute these changes to PHP and maybe work a little more on
the internals of PHP after that.

Anyway, could you please help in finding a consensus for the changes? Could
I get an wiki account to file all
new changes for a vote, too?

Thanks,

Robert Eisele


Re: [PHP-DEV] PHP patches

2011-06-17 Thread Sebastian Bergmann

On 06/17/2011 09:58 AM, Robert Eisele wrote:

[...]


 Hello Robert,

 welcome to this list. I think it would be best if you propose the
 patches individually instead of proposing one big patch.

 Best,
Sebastian

--
Sebastian BergmannCo-Founder and Principal Consultant
http://sebastian-bergmann.de/   http://thePHP.cc/

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Hannes Magnusson
On Fri, Jun 17, 2011 at 18:54, Derick Rethans der...@php.net wrote:
 On Fri, 17 Jun 2011, Derick Rethans wrote:

 On Fri, 17 Jun 2011, Stas Malyshev wrote:

   If either of the dates use a TLA timezone (EDT, PST, GMT), rather
   than the long name (Europe/London, Indian/Kerguelen,
   America/Kentucky/Louisville), then that date is altered.
 
  Yes, this seems to be because TLA ones rely on -z and -dst which get
  reset in timelib_unixtime2gmt() while other one relies on tzinfo which
  is kept intact.

 Yup. I'm fixing it right now.

 Done... I had to do it by making a backup for now. It should be looked
 at again though, and I've added that to my (long) todo list.

Does it mean that all the tests Daniel added should work now?
http://news.php.net/php.cvs/65174

-Hannes

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PHP patches

2011-06-17 Thread Robert Eisele
Sebastian,

Thanks for your welcome. I thought I split up the patch into smaller
per-problem patches if I know what's new and what needs a patch for the
RFC. Sorry for the newbe questions, but should I add a patch for every
proposal; and if so, should I add it directly to the mail as attachement or
as external reference?

Should I add duplicates with a patch? I've seen, e.g., short array syntax
and binary numbers like in C# and python are already on the list of features
for PHP5.4. Is there a chance to get new features into PHP5.4 via vote? Many
comments of the sites, I've mentioned, indicate that they would be glad to
see some of these changes in 5.4 - myself included.

Robert

2011/6/17 Sebastian Bergmann sebast...@php.net

 On 06/17/2011 09:58 AM, Robert Eisele wrote:

 [...]


  Hello Robert,

  welcome to this list. I think it would be best if you propose the
  patches individually instead of proposing one big patch.

  Best,
 Sebastian

 --
 Sebastian BergmannCo-Founder and Principal Consultant
 http://sebastian-bergmann.de/   http://thePHP.cc/

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] PHP patches

2011-06-17 Thread Stas Malyshev

Hi!

On 6/17/11 10:50 AM, Robert Eisele wrote:

Should I add duplicates with a patch? I've seen, e.g., short array syntax
and binary numbers like in C# and python are already on the list of features
for PHP5.4. Is there a chance to get new features into PHP5.4 via vote? Many


The list of things that are considered for vote for 5.4 is listed here: 
https://wiki.php.net/todo/php54
I think as we plan to start the release cycle for 5.4 shortly and we 
have good bunch of new stuff there (or planned to be there) already, we 
shouldn't add to this list now unless it's a) something small and b) 
something that is recognized as really great idea and universally 
cheered and welcomed. But if you have something that you think fits, you 
are welcome to propose it on the list. Also, if you have something that 
you think is good, though not necessarily for 5.4, you're welcome to 
write and RFC and propose it too.

--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PHP patches

2011-06-17 Thread Lester Caine

Sebastian Bergmann wrote:

[...]


  Hello Robert,

  welcome to this list. I think it would be best if you propose the
  patches individually instead of proposing one big patch.


Especially with little nuggets like

Deleted short open tags and ?php= is the new ?=


Don't have time to go through everything else there so there may be others that 
are not acceptable. $_REQUEST certainly has a place in my code base ...


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Stas Malyshev

Hi!


Does it mean that all the tests Daniel added should work now?
http://news.php.net/php.cvs/65174


Unfortunately, not yet. There seems to be another bug there, diff works 
fine now but add gives wrong result.

--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Stas Malyshev

Hi!


Does it mean that all the tests Daniel added should work now?
http://news.php.net/php.cvs/65174


Looks like ts-date conversion is broken on TLA timezones. Try:

?php
$t   = new DateTime('2010-11-06 18:38:28 EDT');  // prev, zt2
$ts = $t-format('U');
var_dump($ts);
$t-setTimestamp($ts);
var_dump($t);

That produces:

object(DateTime)#1 (3) {
  [date]=
  string(19) 2010-11-06 17:38:28
  [timezone_type]=
  int(2)
  [timezone]=
  string(3) EDT
}

Which obviously is not what it should be. Looks like 
timelib_unixtime2gmt() or timelib_update_from_sse() has some bug that 
breaks it...


--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] New function http_response_code() to PHP5.4 Branch

2011-06-17 Thread Paul Dragoonis
Hi there,

I'm requesting my function be put into the 5.4 branch.

I added a function back in the 5.3 phase to obtain missing
functionality of HEAD.c (and /ext/standard/ in general), but since it
wasn't a bug fix then it wasn't suitable to add to a 5.3.x series.

The function is http_response_code() - Link:
http://lxr.php.net/opengrok/xref/PHP_TRUNK/ext/standard/head.c#285

when you set the HTTP status code in header(...); or in the param of
header, like: header(..., null, 404); then at a later date this
can't be obtained again by any PHP function.

Can this be added to 5_4 please?

Thanks,
Paul Dragoonis.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New function http_response_code() to PHP5.4 Branch

2011-06-17 Thread Kalle Sommer Nielsen
Hi Paul

2011/6/18 Paul Dragoonis dragoo...@php.net:
 Hi there,

 I'm requesting my function be put into the 5.4 branch.

 I added a function back in the 5.3 phase to obtain missing
 functionality of HEAD.c (and /ext/standard/ in general), but since it
 wasn't a bug fix then it wasn't suitable to add to a 5.3.x series.

 The function is http_response_code() - Link:
 http://lxr.php.net/opengrok/xref/PHP_TRUNK/ext/standard/head.c#285

 when you set the HTTP status code in header(...); or in the param of
 header, like: header(..., null, 404); then at a later date this
 can't be obtained again by any PHP function.

 Can this be added to 5_4 please?

I'll merge it within the weekend

 Thanks,
 Paul Dragoonis.

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
regards,

Kalle Sommer Nielsen
ka...@php.net

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] New function http_response_code() to PHP5.4 Branch

2011-06-17 Thread Paul Dragoonis
On Fri, Jun 17, 2011 at 11:18 PM, Kalle Sommer Nielsen ka...@php.net wrote:
 Hi Paul

 2011/6/18 Paul Dragoonis dragoo...@php.net:
 Hi there,

 I'm requesting my function be put into the 5.4 branch.

 I added a function back in the 5.3 phase to obtain missing
 functionality of HEAD.c (and /ext/standard/ in general), but since it
 wasn't a bug fix then it wasn't suitable to add to a 5.3.x series.

 The function is http_response_code() - Link:
 http://lxr.php.net/opengrok/xref/PHP_TRUNK/ext/standard/head.c#285

 when you set the HTTP status code in header(...); or in the param of
 header, like: header(..., null, 404); then at a later date this
 can't be obtained again by any PHP function.

 Can this be added to 5_4 please?

 I'll merge it within the weekend

Cheers Kalle!


 Thanks,
 Paul Dragoonis.

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php





 --
 regards,

 Kalle Sommer Nielsen
 ka...@php.net


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Daniel Convissor
Hi Stas:

 $start = new DateTime('2010-10-04 02:18:48 EDT');
 $end   = new DateTime('2010-11-06 18:38:28 EDT');
 $int = $start-diff($end);
... snip ...
 As you can see, the date in $start changed, even though it shouldn't
 happen.

Funny you should mention that now.  I ran into the same exact issue as
I was reworking the DateTime unit tests yesterday.  I came up with a
.phpt for it, and another one for a similar problem with DateTime::add(),
though I was waiting to commit them until bugs.php.net was back up so
I could get bug numbers for them.

I just updated my checkout and the diff() problem is fixed, but the
add() one still exists.  bug.add.zone2.phpt has now been committed.  In
brief, calling add() on DateTime objects with zone type2 pushes back the
time by an hour.  For example:

?php
$interval = new DateInterval('PT2H1M');
$date2 = new DateTime('2010-10-04 02:18:48 EDT');
echo $interval-format('Add %h hours %i minutes') . \n;
$date2-add($interval);
echo 'Zone Type 2: ' . $date2-format('Y-m-d H:i:s T') . \n;
?

Output:
Zone Type 2: 2010-10-04 03:19:48 EDT

Expected:
Zone Type 2: 2010-10-04 04:19:48 EDT

Thanks,

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] date_diff broken?

2011-06-17 Thread Daniel Convissor
Hi Hannes:

On Fri, Jun 17, 2011 at 07:11:53PM +0200, Hannes Magnusson wrote:
 
 Does it mean that all the tests Daniel added should work now?
 http://news.php.net/php.cvs/65174

Alas, no.  There are other bugs in the bed.

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php