FAQ

Le 25/04/2014 17:23, Anatol Belski a écrit :
Commit: c1aa9baf29d1a20fa60c1cef3979a80014f6677b
Author: Anatol Belski <ab@php.net> Fri, 25 Apr 2014 17:23:26 +0200
Parents: 03c703b8bd55679edf30fe17529fab0c2281b01f
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master

Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c1aa9baf29d1a20fa60c1cef3979a80014f6677b

It seems this fix breaks Horde (Horde_Imap_Client).

Here is the code:

https://github.com/horde/horde/blob/master/framework/Imap_Client/lib/Horde/Imap/Client/DateTime.php

If first __construct call fails, this=NULL and other call have no effect.

Probably the code seems a bit ugly... but...

Any idea ?
- realloc "this" before php_date_initialize ?

Remi.

Search Discussions

  • Remi Collet at Jun 4, 2014 at 6:41 pm

    Le 04/06/2014 20:25, Remi Collet a écrit :
    Le 25/04/2014 17:23, Anatol Belski a écrit :
    Commit: c1aa9baf29d1a20fa60c1cef3979a80014f6677b
    Author: Anatol Belski <ab@php.net> Fri, 25 Apr 2014 17:23:26 +0200
    Parents: 03c703b8bd55679edf30fe17529fab0c2281b01f
    Branches: PHP-5.4 PHP-5.5 PHP-5.6 master

    Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c1aa9baf29d1a20fa60c1cef3979a80014f6677b

    It seems this fix breaks Horde (Horde_Imap_Client).

    Here is the code:

    https://github.com/horde/horde/blob/master/framework/Imap_Client/lib/Horde/Imap/Client/DateTime.php

    If first __construct call fails, this=NULL and other call have no effect.

    Probably the code seems a bit ugly... but...

    Any idea ?
    - realloc "this" before php_date_initialize ?

    Remi.
    Simple reproducer:

    <?php

    class Foo extends DateTime {
         public function __construct($time = null) {
             $tz = new DateTimeZone('UTC');
             try {
                 echo "First try\n";
                 parent::__construct($time, $tz);
                 return;
             } catch (Exception $e) {
                 echo "Second try\n";
                 parent::__construct($time.'C', $tz);
             }
         }
    }
    $date = '12 Sep 2007 15:49:12 UT';
    var_dump(new Foo($date));


    Works with php 5.4.28, 5.5.12
    Return NULL with php 5.4.29, 5.5.13 and 5.6.0beta3

    Remi.
  • Anatol Belski at Jun 4, 2014 at 10:36 pm
    Hi Remi,
    On Wed, June 4, 2014 20:41, Remi Collet wrote:
    Le 04/06/2014 20:25, Remi Collet a écrit :
    Le 25/04/2014 17:23, Anatol Belski a écrit :
    Commit: c1aa9baf29d1a20fa60c1cef3979a80014f6677b
    Author: Anatol Belski <ab@php.net> Fri, 25 Apr 2014
    17:23:26
    +0200
    Parents: 03c703b8bd55679edf30fe17529fab0c2281b01f
    Branches: PHP-5.4 PHP-5.5 PHP-5.6 master


    Link:
    http://git.php.net/?p=php-src.git;a=commitdiff;h=c1aa9baf29d1a20fa60c1
    cef3979a80014f6677b

    It seems this fix breaks Horde (Horde_Imap_Client).


    Here is the code:


    https://github.com/horde/horde/blob/master/framework/Imap_Client/lib/Ho
    rde/Imap/Client/DateTime.php

    If first __construct call fails, this=NULL and other call have no
    effect.

    Probably the code seems a bit ugly... but...


    Any idea ?
    - realloc "this" before php_date_initialize ?


    Remi.

    Simple reproducer:


    <?php


    class Foo extends DateTime { public function __construct($time = null) {
    $tz = new DateTimeZone('UTC');
    try { echo "First try\n"; parent::__construct($time, $tz);
    return; } catch (Exception $e) {
    echo "Second try\n"; parent::__construct($time.'C', $tz);
    }
    }
    }
    $date = '12 Sep 2007 15:49:12 UT';
    var_dump(new Foo($date));
    Oh god, why in the world do they have a return there, if they intend to
    retry with a corrected string :) Yes, the string '12 Sep 2007 15:49:12 UT'
    is invalid and timelib would complain about the nonexistent timezone, then
    the script will jump out on that first return.

    Prior to this fix, no check for php_date_initialize() was done, means the
    object was created in anyway. And the strange thing is, that timelib
    returns 0 (means error) but indeed could parse that invalid string. So
    looking how to unite those two contrasts now. Thanks for the info.

    Regards

    Anatol
  • Remi Collet at Jun 5, 2014 at 5:54 am
    Prior to this fix, no check for php_date_initialize() was done,
    Fix proposal attached

    Notice, bug67118.phpt is not ok, as it doesn't reproduce the segfault
    which is supposed to be fixed...

    With this patch, reproducer attached in the bug report doesn't segfault
    and now raise an exception:

    Warning: date_format(): The DateTime object has not been correctly
    initialized by its constructor in /dev/shm/php-5.6.0beta4/test.php on
    line 13


    Remi.
  • Remi Collet at Jun 5, 2014 at 6:47 am
    Same patch with unit test.

    $ make test TESTS=ext/date/tests

    =====================================================================
    Number of tests : 587 561
    Tests skipped : 26 ( 4.4%) --------
    Tests warned : 0 ( 0.0%) ( 0.0%)
    Tests failed : 0 ( 0.0%) ( 0.0%)
    Expected fail : 20 ( 3.4%) ( 3.6%)
    Tests passed : 541 ( 92.2%) ( 96.4%)
    ---------------------------------------------------------------------
    Time taken : 15 seconds
    =====================================================================

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedJun 4, '14 at 6:25p
activeJun 5, '14 at 6:47a
posts5
users2
websitephp.net

2 users in discussion

Remi Collet: 4 posts Anatol Belski: 1 post

People

Translate

site design / logo © 2018 Grokbase