derick          Thu Jan 17 19:59:00 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/date/tests     bug43003.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/date   php_date.c 
  Log:
  - Fixed bug #43003 (Invalid timezone reported for DateTime objects constructed
    using a timestamp).
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.73&r2=1.2027.2.547.2.965.2.74&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.73 
php-src/NEWS:1.2027.2.547.2.965.2.74
--- php-src/NEWS:1.2027.2.547.2.965.2.73        Thu Jan 17 18:49:31 2008
+++ php-src/NEWS        Thu Jan 17 19:58:59 2008
@@ -79,6 +79,8 @@
 
 - Fixed bug #43527 (DateTime created from a timestamp reports environment
   timezone). (Derick)
+- Fixed bug #43003 (Invalid timezone reported for DateTime objects constructed
+  using a timestamp). (Derick)
 - Fixed bug #43143 (Warning about empty IV with MCRYPT_MODE_ECB). (Derick)
 - Fixed bug #43136 (possible crash on script execution timeout.
   The EG(function_state_ptr) is completely removed,
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.43.2.45.2.51.2.9&r2=1.43.2.45.2.51.2.10&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.45.2.51.2.9 
php-src/ext/date/php_date.c:1.43.2.45.2.51.2.10
--- php-src/ext/date/php_date.c:1.43.2.45.2.51.2.9      Thu Jan 17 18:49:31 2008
+++ php-src/ext/date/php_date.c Thu Jan 17 19:59:00 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_date.c,v 1.43.2.45.2.51.2.9 2008/01/17 18:49:31 derick Exp $ */
+/* $Id: php_date.c,v 1.43.2.45.2.51.2.10 2008/01/17 19:59:00 derick Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -273,6 +273,7 @@
 
 struct _php_timezone_obj {
        zend_object     std;
+       int             initialized;
        int             type;
        union {
                timelib_tzinfo *tz; // TIMELIB_ZONETYPE_ID;
@@ -1632,6 +1633,7 @@
        
        zend_objects_clone_members(&new_obj->std, new_ov, &old_obj->std, 
Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
        new_obj->type = old_obj->type;
+       new_obj->initialized = 1;
        switch (new_obj->type) {
                case TIMELIB_ZONETYPE_ID:
                        new_obj->tzi.tz = old_obj->tzi.tz;
@@ -2052,6 +2054,7 @@
        if (dateobj->time->is_localtime/* && dateobj->time->tz_info*/) {
                date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
                tzobj = (php_timezone_obj *) 
zend_object_store_get_object(return_value TSRMLS_CC);
+               tzobj->initialized = 1;
                tzobj->type = dateobj->time->zone_type;
                switch (dateobj->time->zone_type) {
                        case TIMELIB_ZONETYPE_ID:
@@ -2277,6 +2280,7 @@
                        tzobj = zend_object_store_get_object(getThis() 
TSRMLS_CC);
                        tzobj->type = TIMELIB_ZONETYPE_ID;
                        tzobj->tzi.tz = tzi;
+                       tzobj->initialized = 1;
                } else {
                        ZVAL_NULL(getThis());
                }
@@ -2297,7 +2301,7 @@
                RETURN_FALSE;
        }
        tzobj = (php_timezone_obj *) zend_object_store_get_object(object 
TSRMLS_CC);
-       DATE_CHECK_INITIALIZED(tzobj->tzi.tz, DateTimeZone);
+       DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone);
 
        switch (tzobj->type) {
                case TIMELIB_ZONETYPE_ID:
@@ -2360,7 +2364,7 @@
                RETURN_FALSE;
        }
        tzobj = (php_timezone_obj *) zend_object_store_get_object(object 
TSRMLS_CC);
-       DATE_CHECK_INITIALIZED(tzobj->tzi.tz, DateTimeZone);
+       DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone);
        dateobj = (php_date_obj *) zend_object_store_get_object(dateobject 
TSRMLS_CC);
        DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
 
@@ -2383,7 +2387,7 @@
                RETURN_FALSE;
        }
        tzobj = (php_timezone_obj *) zend_object_store_get_object(object 
TSRMLS_CC);
-       DATE_CHECK_INITIALIZED(tzobj->tzi.tz, DateTimeZone);
+       DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone);
        if (tzobj->type != TIMELIB_ZONETYPE_ID) {
                RETURN_FALSE;
        }

http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/bug43003.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/bug43003.phpt
+++ php-src/ext/date/tests/bug43003.phpt
--TEST--
Bug #43003 (Invalid timezone reported for DateTime objects constructed using a 
timestamp)
--FILE--
<?php
$oDateTest = new DateTime("@0", new DateTimeZone(date_default_timezone_get()));
echo $oDateTest->getTimezone()->getName().": " .  $oDateTest->format("Y-m-d 
H:i:s")."\n";

$oDateTest->setTimezone(new DateTimeZone("UTC"));
echo $oDateTest->getTimezone()->getName().": " .  $oDateTest->format("Y-m-d 
H:i:s")."\n";

$oDateTest->setTimezone(new DateTimeZone(date_default_timezone_get()));
echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d 
H:i:s")."\n";

$oDateTest = new DateTime("@0");
echo $oDateTest->getTimezone()->getName().": " .  $oDateTest->format("Y-m-d 
H:i:s")."\n";

$oDateTest->setTimezone( new DateTimeZone(date_default_timezone_get()));
echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d 
H:i:s")."\n";
?>
--EXPECT--
+00:00: 1970-01-01 00:00:00
UTC: 1970-01-01 00:00:00
Europe/Oslo: 1970-01-01 01:00:00
+00:00: 1970-01-01 00:00:00
Europe/Oslo: 1970-01-01 01:00:00

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to