summaryrefslogtreecommitdiff
path: root/ext/intl/dateformat/dateformat_create.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ext/intl/dateformat/dateformat_create.cpp')
-rw-r--r--ext/intl/dateformat/dateformat_create.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp
index a2899f7974..4a272aa45f 100644
--- a/ext/intl/dateformat/dateformat_create.cpp
+++ b/ext/intl/dateformat/dateformat_create.cpp
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -41,19 +41,19 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
zval *object;
const char *locale_str;
- int locale_len = 0;
+ size_t locale_len = 0;
Locale locale;
- long date_type = 0;
- long time_type = 0;
+ zend_long date_type = 0;
+ zend_long time_type = 0;
zval *calendar_zv = NULL;
Calendar *calendar = NULL;
- long calendar_type;
+ zend_long calendar_type;
bool calendar_owned;
- zval **timezone_zv = NULL;
+ zval *timezone_zv = NULL;
TimeZone *timezone = NULL;
bool explicit_tz;
char* pattern_str = NULL;
- int pattern_str_len = 0;
+ size_t pattern_str_len = 0;
UChar* svalue = NULL; /* UTF-16 pattern_str */
int slength = 0;
IntlDateFormatter_object* dfo;
@@ -61,13 +61,13 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
intl_error_reset(NULL TSRMLS_CC);
object = return_value;
/* Parse parameters. */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sll|Zzs",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sll|zzs",
&locale_str, &locale_len, &date_type, &time_type, &timezone_zv,
&calendar_zv, &pattern_str, &pattern_str_len) == FAILURE) {
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
"unable to parse input parameters", 0 TSRMLS_CC);
- zval_dtor(return_value);
- RETURN_NULL();
+ Z_OBJ_P(return_value) = NULL;
+ return;
}
INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
@@ -93,7 +93,7 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
}
/* process timezone */
- explicit_tz = timezone_zv != NULL && Z_TYPE_PP(timezone_zv) != IS_NULL;
+ explicit_tz = timezone_zv != NULL && Z_TYPE_P(timezone_zv) != IS_NULL;
if (explicit_tz || calendar_owned ) {
//we have an explicit time zone or a non-object calendar
@@ -162,8 +162,7 @@ error:
}
if (U_FAILURE(intl_error_get_code(NULL TSRMLS_CC))) {
/* free_object handles partially constructed instances fine */
- zval_dtor(return_value);
- RETVAL_NULL();
+ Z_OBJ_P(return_value) = NULL;
}
}
/* }}} */
@@ -177,6 +176,9 @@ U_CFUNC PHP_FUNCTION( datefmt_create )
{
object_init_ex( return_value, IntlDateFormatter_ce_ptr );
datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
+ RETURN_NULL();
+ }
}
/* }}} */
@@ -185,9 +187,17 @@ U_CFUNC PHP_FUNCTION( datefmt_create )
*/
U_CFUNC PHP_METHOD( IntlDateFormatter, __construct )
{
+ zval orig_this = *getThis();
+
/* return_value param is being changed, therefore we will always return
* NULL here */
return_value = getThis();
datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+
+ if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
+ zend_object_store_ctor_failed(Z_OBJ(orig_this) TSRMLS_CC);
+ zval_dtor(&orig_this);
+ ZEND_CTOR_MAKE_NULL();
+ }
}
/* }}} */