com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/date/php _date.c
| From: | Tjerk Anne Meesters | Date: | Wed, 13 Aug 2014 12:15:52 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/date/php _date.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-79834@lists.php.net to get a copy of this message | ||
Commit: c5f619ba6fd1182799e2e43dc60f008bd43da3dc
Author: Tjerk Meesters <datibbaw@php.net> Wed, 13 Aug 2014 20:15:52 +0800
Parents: 934c35f58685cde2e0bc7e649486db7b488758e9 f6896e4395e89ceeacd8f8a940cbafeeee3ac4a3
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c5f619ba6fd1182799e2e43dc60f008bd43da3dc
Log:
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
Fixed #66091
Conflicts:
ext/date/php_date.c
Bugs:
https://bugs.php.net/66091
Changed paths:
MM ext/date/php_date.c
Diff:
diff --cc ext/date/php_date.c
index 6ff0586,92e9480..39b25d9
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@@ -2658,26 -2523,6 +2659,31 @@@ PHP_FUNCTION(date_create
}
/* }}} */
+/* {{{ proto DateTime date_create_immutable([string time[, DateTimeZone object]])
+ Returns new DateTime object
+*/
+PHP_FUNCTION(date_create_immutable)
+{
+ zval *timezone_object = NULL;
+ char *time_str = NULL;
+ int time_str_len = 0;
++ zval datetime_object;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str,
&time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
+ RETURN_FALSE;
+ }
+
- php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC);
- if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str,
time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
++ php_date_instantiate(date_ce_immutable, &datetime_object TSRMLS_CC);
++ if (!php_date_initialize(zend_object_store_get_object(&datetime_object TSRMLS_CC), time_str,
time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
++ zval_dtor(&datetime_object);
+ RETURN_FALSE;
++ } else {
++ zval *datetime_object_ptr = &datetime_object;
++ RETVAL_ZVAL(datetime_object_ptr, 0, 0);
+ }
+}
+/* }}} */
+
/* {{{ proto DateTime date_create_from_format(string format, string time[, DateTimeZone object])
Returns new DateTime object formatted according to the specified format
*/
@@@ -2698,26 -2548,6 +2709,31 @@@ PHP_FUNCTION(date_create_from_format
}
/* }}} */
+/* {{{ proto DateTime date_create_immutable_from_format(string format, string time[, DateTimeZone
object])
+ Returns new DateTime object formatted according to the specified format
+*/
+PHP_FUNCTION(date_create_immutable_from_format)
+{
+ zval *timezone_object = NULL;
+ char *time_str = NULL, *format_str = NULL;
+ int time_str_len = 0, format_str_len = 0;
++ zval datetime_object;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|O", &format_str,
&format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) ==
FAILURE) {
+ RETURN_FALSE;
+ }
+
- php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC);
- if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str,
time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
++ php_date_instantiate(date_ce_immutable, &datetime_object TSRMLS_CC);
++ if (!php_date_initialize(zend_object_store_get_object(&datetime_object TSRMLS_CC), time_str,
time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
++ zval_dtor(&datetime_object);
+ RETURN_FALSE;
++ } else {
++ zval *datetime_object_ptr = &datetime_object;
++ RETVAL_ZVAL(datetime_object_ptr, 0, 0);
+ }
+}
+/* }}} */
+
/* {{{ proto DateTime::__construct([string time[, DateTimeZone object]])
Creates new DateTime object
*/
@@@ -2736,25 -2566,7 +2752,25 @@@ PHP_METHOD(DateTime, __construct
}
/* }}} */
+/* {{{ proto DateTimeImmutable::__construct([string time[, DateTimeZone object]])
+ Creates new DateTimeImmutable object
+*/
+PHP_METHOD(DateTimeImmutable, __construct)
+{
+ zval *timezone_object = NULL;
+ char *time_str = NULL;
+ int time_str_len = 0;
+ zend_error_handling error_handling;
+
+ zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str,
&time_str_len, &timezone_object, date_ce_timezone)) {
+ php_date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len,
NULL, timezone_object, 1 TSRMLS_CC);
+ }
+ zend_restore_error_handling(&error_handling TSRMLS_CC);
+}
+/* }}} */
+
- static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dateobj, HashTable
*myht TSRMLS_DC)
+ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht TSRMLS_DC)
{
zval **z_date = NULL;
zval **z_timezone = NULL;
@@@ -2830,28 -2642,6 +2846,28 @@@ PHP_METHOD(DateTime, __set_state
}
/* }}} */
+/* {{{ proto DateTimeImmutable::__set_state()
+*/
+PHP_METHOD(DateTimeImmutable, __set_state)
+{
+ php_date_obj *dateobj;
+ zval *array;
+ HashTable *myht;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ myht = HASH_OF(array);
+
+ php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC);
+ dateobj = (php_date_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- if (!php_date_initialize_from_hash(&return_value, &dateobj, myht TSRMLS_CC)) {
++ if (!php_date_initialize_from_hash(&dateobj, myht TSRMLS_CC)) {
+ php_error(E_ERROR, "Invalid serialization data for DateTimeImmutable object");
+ }
+}
+/* }}} */
+
/* {{{ proto DateTime::__wakeup()
*/
PHP_METHOD(DateTime, __wakeup)