@@ -2218,7 +2218,7 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, const char *time_str, size
2218
2218
/* If called from a constructor throw an exception */
2219
2219
if ((flags & PHP_DATE_INIT_CTOR ) && err && err -> error_count ) {
2220
2220
/* spit out the first library error message, at least */
2221
- zend_throw_error ( zend_ce_exception , "Failed to parse time string (%s) at position %d (%c): %s" , time_str ,
2221
+ zend_throw_exception_ex ( NULL , 0 , "Failed to parse time string (%s) at position %d (%c): %s" , time_str ,
2222
2222
err -> error_messages [0 ].position , err -> error_messages [0 ].character , err -> error_messages [0 ].message );
2223
2223
}
2224
2224
if (err && err -> error_count ) {
@@ -3691,7 +3691,7 @@ static bool date_interval_initialize(timelib_rel_time **rt, /*const*/ char *form
3691
3691
timelib_strtointerval (format , format_length , & b , & e , & p , & r , & errors );
3692
3692
3693
3693
if (errors -> error_count > 0 ) {
3694
- zend_throw_error ( zend_ce_exception , "Unknown or bad format (%s)" , format );
3694
+ zend_throw_exception_ex ( NULL , 0 , "Unknown or bad format (%s)" , format );
3695
3695
retval = false;
3696
3696
if (p ) {
3697
3697
timelib_rel_time_dtor (p );
@@ -3707,7 +3707,7 @@ static bool date_interval_initialize(timelib_rel_time **rt, /*const*/ char *form
3707
3707
* rt = timelib_diff (b , e );
3708
3708
retval = true;
3709
3709
} else {
3710
- zend_throw_error ( zend_ce_exception , "Failed to parse interval (%s)" , format );
3710
+ zend_throw_exception_ex ( NULL , 0 , "Failed to parse interval (%s)" , format );
3711
3711
retval = false;
3712
3712
}
3713
3713
}
@@ -4110,17 +4110,19 @@ PHP_FUNCTION(date_interval_format)
4110
4110
}
4111
4111
/* }}} */
4112
4112
4113
- static void date_period_initialize (timelib_time * * st , timelib_time * * et , timelib_rel_time * * d , zend_long * recurrences , /*const*/ char * format , size_t format_length ) /* {{{ */
4113
+ static bool date_period_initialize (timelib_time * * st , timelib_time * * et , timelib_rel_time * * d , zend_long * recurrences , /*const*/ char * format , size_t format_length ) /* {{{ */
4114
4114
{
4115
4115
timelib_time * b = NULL , * e = NULL ;
4116
4116
timelib_rel_time * p = NULL ;
4117
4117
int r = 0 ;
4118
4118
timelib_error_container * errors ;
4119
+ bool retval = false;
4119
4120
4120
4121
timelib_strtointerval (format , format_length , & b , & e , & p , & r , & errors );
4121
4122
4122
4123
if (errors -> error_count > 0 ) {
4123
- zend_throw_error (zend_ce_exception , "Unknown or bad format (%s)" , format );
4124
+ retval = false;
4125
+ zend_throw_exception_ex (NULL , 0 , "Unknown or bad format (%s)" , format );
4124
4126
if (b ) {
4125
4127
timelib_time_dtor (b );
4126
4128
}
@@ -4135,8 +4137,10 @@ static void date_period_initialize(timelib_time **st, timelib_time **et, timelib
4135
4137
* et = e ;
4136
4138
* d = p ;
4137
4139
* recurrences = r ;
4140
+ retval = true;
4138
4141
}
4139
4142
timelib_error_container_dtor (errors );
4143
+ return retval ;
4140
4144
} /* }}} */
4141
4145
4142
4146
/* {{{ Creates new DatePeriod object. */
@@ -4163,26 +4167,25 @@ PHP_METHOD(DatePeriod, __construct)
4163
4167
dpobj -> current = NULL ;
4164
4168
4165
4169
if (isostr ) {
4166
- date_period_initialize (& (dpobj -> start ), & (dpobj -> end ), & (dpobj -> interval ), & recurrences , isostr , isostr_len );
4167
- if (EG (exception )) {
4170
+ if (!date_period_initialize (& (dpobj -> start ), & (dpobj -> end ), & (dpobj -> interval ), & recurrences , isostr , isostr_len )) {
4168
4171
RETURN_THROWS ();
4169
4172
}
4170
4173
4171
4174
if (dpobj -> start == NULL ) {
4172
4175
zend_string * func = get_active_function_or_method_name ();
4173
- zend_throw_error ( zend_ce_exception , "%s(): ISO interval must contain a start date, \"%s\" given" , ZSTR_VAL (func ), isostr );
4176
+ zend_throw_exception_ex ( NULL , 0 , "%s(): ISO interval must contain a start date, \"%s\" given" , ZSTR_VAL (func ), isostr );
4174
4177
zend_string_release (func );
4175
4178
RETURN_THROWS ();
4176
4179
}
4177
4180
if (dpobj -> interval == NULL ) {
4178
4181
zend_string * func = get_active_function_or_method_name ();
4179
- zend_throw_error ( zend_ce_exception , "%s(): ISO interval must contain an interval, \"%s\" given" , ZSTR_VAL (func ), isostr );
4182
+ zend_throw_exception_ex ( NULL , 0 , "%s(): ISO interval must contain an interval, \"%s\" given" , ZSTR_VAL (func ), isostr );
4180
4183
zend_string_release (func );
4181
4184
RETURN_THROWS ();
4182
4185
}
4183
4186
if (dpobj -> end == NULL && recurrences == 0 ) {
4184
4187
zend_string * func = get_active_function_or_method_name ();
4185
- zend_throw_error ( zend_ce_exception , "%s(): ISO interval must contain an end date or a recurrence count, \"%s\" given" , ZSTR_VAL (func ), isostr );
4188
+ zend_throw_exception_ex ( NULL , 0 , "%s(): ISO interval must contain an end date or a recurrence count, \"%s\" given" , ZSTR_VAL (func ), isostr );
4186
4189
zend_string_release (func );
4187
4190
RETURN_THROWS ();
4188
4191
}
@@ -4224,7 +4227,7 @@ PHP_METHOD(DatePeriod, __construct)
4224
4227
4225
4228
if (dpobj -> end == NULL && recurrences < 1 ) {
4226
4229
zend_string * func = get_active_function_or_method_name ();
4227
- zend_throw_error ( zend_ce_exception , "%s(): Recurrence count must be greater than 0" , ZSTR_VAL (func ));
4230
+ zend_throw_exception_ex ( NULL , 0 , "%s(): Recurrence count must be greater than 0" , ZSTR_VAL (func ));
4228
4231
zend_string_release (func );
4229
4232
RETURN_THROWS ();
4230
4233
}
0 commit comments