From b3a48855ab13bbec5cb679823c6b06fcce1ec396 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 27 Nov 2005 06:51:43 +0000 Subject: [PATCH] Disabled native date class, to prevent pear::date conflict. --- NEWS | 1 + ext/date/php_date.c | 29 ++++++++++++------- ext/date/tests/bug33869.phpt | 12 ++++---- ext/date/tests/bug34087.phpt | 8 ++--- ext/date/tests/bug34676.phpt | 2 +- ext/date/tests/bug34771.phpt | 2 +- .../tests/date_default_timezone_set-1.phpt | 8 ++--- ext/date/tests/mktime-3.phpt | 2 +- ext/date/tests/strtotime.phpt | 2 +- 9 files changed, 37 insertions(+), 29 deletions(-) diff --git a/NEWS b/NEWS index 21697b1f55..c29705210f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2006, PHP 5.1.1 +- Disabled native date class, to prevent pear::date conflict. (Ilia) - Make reflection constants be both PHP and class constants. (Johannes) - Added an additional field $frame['object'] to the result array of debug_backtrace() that contains a reference to the respective object when the diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 9c102c76ad..149f44ca30 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -74,9 +74,8 @@ function_entry date_functions[] = { {NULL, NULL, NULL} }; - -function_entry date_funcs_date[] = { #ifdef EXPERIMENTAL_DATE_SUPPORT +function_entry date_funcs_date[] = { ZEND_NAMED_FE(format, ZEND_FN(date_format), NULL) ZEND_NAMED_FE(modify, ZEND_FN(date_modify), NULL) ZEND_NAMED_FE(getTimezone, ZEND_FN(date_timezone_get), NULL) @@ -85,23 +84,21 @@ function_entry date_funcs_date[] = { ZEND_NAMED_FE(setTime, ZEND_FN(date_time_set), NULL) ZEND_NAMED_FE(setDate, ZEND_FN(date_date_set), NULL) ZEND_NAMED_FE(setISODate, ZEND_FN(date_isodate_set), NULL) -#endif {NULL, NULL, NULL} }; function_entry date_funcs_timezone[] = { -#ifdef EXPERIMENTAL_DATE_SUPPORT ZEND_NAMED_FE(getName, ZEND_FN(timezone_name_get), NULL) ZEND_NAMED_FE(getOffset, ZEND_FN(timezone_offset_get), NULL) ZEND_NAMED_FE(getTransistions, ZEND_FN(timezone_transistions_get), NULL) ZEND_MALIAS(timezone, listAbbreviations, abbreviations_list, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_MALIAS(timezone, listIdentifiers, identifiers_list, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) -#endif {NULL, NULL, NULL} }; -static char* guess_timezone(TSRMLS_D); static void date_register_classes(TSRMLS_D); +#endif +static char* guess_timezone(TSRMLS_D); /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(date) @@ -116,6 +113,7 @@ PHP_INI_BEGIN() PHP_INI_END() /* }}} */ +#ifdef EXPERIMENTAL_DATE_SUPPORT zend_class_entry *date_ce_date, *date_ce_timezone; static zend_object_handlers date_object_handlers_date; @@ -134,7 +132,6 @@ struct _php_timezone_obj { timelib_tzinfo *tz; }; -#ifdef EXPERIMENTAL_DATE_SUPPORT #define DATE_SET_CONTEXT \ zval *object; \ object = getThis(); \ @@ -153,12 +150,11 @@ struct _php_timezone_obj { } \ obj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); \ -#endif - static void date_object_free_storage_date(void *object TSRMLS_DC); static void date_object_free_storage_timezone(void *object TSRMLS_DC); static zend_object_value date_object_new_date(zend_class_entry *class_type TSRMLS_DC); static zend_object_value date_object_new_timezone(zend_class_entry *class_type TSRMLS_DC); +#endif /* {{{ Module struct */ zend_module_entry date_module_entry = { @@ -235,8 +231,19 @@ PHP_MINIT_FUNCTION(date) { ZEND_INIT_MODULE_GLOBALS(date, php_date_init_globals, NULL); REGISTER_INI_ENTRIES(); - +#ifdef EXPERIMENTAL_DATE_SUPPORT date_register_classes(TSRMLS_C); +#endif + REGISTER_STRING_CONSTANT("DATE_ATOM", DATE_FORMAT_ISO8601, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_COOKIE", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_ISO8601", DATE_FORMAT_ISO8601, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_RFC822", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_RFC850", DATE_FORMAT_RFC1036, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_RFC1036", DATE_FORMAT_RFC1036, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_RFC1123", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_RFC2822", DATE_FORMAT_RFC2822, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_RSS", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("DATE_W3C", DATE_FORMAT_ISO8601, CONST_CS | CONST_PERSISTENT); php_date_global_timezone_db = NULL; php_date_global_timezone_db_enabled = 0; @@ -1002,6 +1009,7 @@ PHP_FUNCTION(getdate) } /* }}} */ +#ifdef EXPERIMENTAL_DATE_SUPPORT static void date_register_classes(TSRMLS_D) { zend_class_entry ce_date, ce_timezone; @@ -1107,7 +1115,6 @@ static void date_object_free_storage_timezone(void *object TSRMLS_DC) efree(object); } -#ifdef EXPERIMENTAL_DATE_SUPPORT /* Advanced Interface */ static zval * date_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC) { diff --git a/ext/date/tests/bug33869.phpt b/ext/date/tests/bug33869.phpt index fc2c4833fa..6957a6b7e2 100644 --- a/ext/date/tests/bug33869.phpt +++ b/ext/date/tests/bug33869.phpt @@ -4,17 +4,17 @@ Bug #33869 (strtotime() doesn't parse "+1days" format) --EXPECT-- diff --git a/ext/date/tests/bug34087.phpt b/ext/date/tests/bug34087.phpt index 76640c3954..3fa3885481 100644 --- a/ext/date/tests/bug34087.phpt +++ b/ext/date/tests/bug34087.phpt @@ -6,10 +6,10 @@ date_default_timezone_set("UTC"); echo "Y/m/d: ", strtotime("2005/8/12"), "\n"; echo "Y-m-d: ", strtotime("2005-8-12"), "\n"; -echo date(date::ISO8601, strtotime("2005/1/2")), "\n"; -echo date(date::ISO8601, strtotime("2005/01/02")), "\n"; -echo date(date::ISO8601, strtotime("2005/01/2")), "\n"; -echo date(date::ISO8601, strtotime("2005/1/02")), "\n"; +echo date(DATE_ISO8601, strtotime("2005/1/2")), "\n"; +echo date(DATE_ISO8601, strtotime("2005/01/02")), "\n"; +echo date(DATE_ISO8601, strtotime("2005/01/2")), "\n"; +echo date(DATE_ISO8601, strtotime("2005/1/02")), "\n"; ?> --EXPECT-- Y/m/d: 1123804800 diff --git a/ext/date/tests/bug34676.phpt b/ext/date/tests/bug34676.phpt index 84f58e922a..6f616feb40 100644 --- a/ext/date/tests/bug34676.phpt +++ b/ext/date/tests/bug34676.phpt @@ -10,7 +10,7 @@ $tests = array( foreach ($tests as $test) { $t = strtotime("2005-12-22 ". $test); - printf("%-10s => %s\n", $test, date(date::ISO8601, $t)); + printf("%-10s => %s\n", $test, date(DATE_ISO8601, $t)); } ?> diff --git a/ext/date/tests/bug34771.phpt b/ext/date/tests/bug34771.phpt index bed9511d60..a27d085a1d 100644 --- a/ext/date/tests/bug34771.phpt +++ b/ext/date/tests/bug34771.phpt @@ -13,7 +13,7 @@ $tests = array( foreach ($tests as $test) { $t = strtotime("2005-12-22 ". $test); - printf("%-10s => %s\n", $test, date(date::ISO8601, $t)); + printf("%-10s => %s\n", $test, date(DATE_ISO8601, $t)); } ?> diff --git a/ext/date/tests/date_default_timezone_set-1.phpt b/ext/date/tests/date_default_timezone_set-1.phpt index 3b422a8690..90916e9238 100644 --- a/ext/date/tests/date_default_timezone_set-1.phpt +++ b/ext/date/tests/date_default_timezone_set-1.phpt @@ -12,10 +12,10 @@ date.timezone= $date4 = strtotime("2005-07-12 08:00:00"); echo date_default_timezone_get(), "\n"; - echo date(date::ISO8601, $date1), "\n"; - echo date(date::ISO8601, $date2), "\n"; - echo date(date::ISO8601, $date3), "\n"; - echo date(date::ISO8601, $date4), "\n"; + echo date(DATE_ISO8601, $date1), "\n"; + echo date(DATE_ISO8601, $date2), "\n"; + echo date(DATE_ISO8601, $date3), "\n"; + echo date(DATE_ISO8601, $date4), "\n"; ?> --EXPECTF-- Strict Standards: strtotime(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We selected 'Europe/London' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_set-1.php on line 3 diff --git a/ext/date/tests/mktime-3.phpt b/ext/date/tests/mktime-3.phpt index 7e9aa62d93..d4ccfbabe4 100644 --- a/ext/date/tests/mktime-3.phpt +++ b/ext/date/tests/mktime-3.phpt @@ -16,7 +16,7 @@ foreach ($tzs as $tz) { if ($ret == FALSE) { echo "out of range\n"; } else { - echo date("F ".date::ISO8601, $ret), "\n"; + echo date("F ".DATE_ISO8601, $ret), "\n"; } } echo "\n"; diff --git a/ext/date/tests/strtotime.phpt b/ext/date/tests/strtotime.phpt index e8eea399d2..6560d7f1fd 100644 --- a/ext/date/tests/strtotime.phpt +++ b/ext/date/tests/strtotime.phpt @@ -8,7 +8,7 @@ $d[] = strtotime("2005-07-14 22:30:41"); $d[] = strtotime("2005-07-14 22:30:41 GMT"); foreach($d as $date) { - echo date(date::ISO8601, $date), "\n"; + echo date(DATE_ISO8601, $date), "\n"; } ?> --EXPECT-- -- 2.50.1