@@ -650,7 +650,8 @@ static PHP_INI_MH(OnUpdate_date_timezone)
650
650
if (stage == PHP_INI_STAGE_RUNTIME ) {
651
651
if (!timelib_timezone_id_is_valid (DATEG (default_timezone ), DATE_TIMEZONEDB )) {
652
652
if (DATEG (default_timezone ) && * DATEG (default_timezone )) {
653
- php_error_docref (NULL , E_WARNING , "Invalid date.timezone value '%s', we selected the timezone 'UTC' for now." , DATEG (default_timezone ));
653
+ zend_value_error ("Invalid date.timezone value '%s'" , DATEG (default_timezone ));
654
+ return FAILURE ;
654
655
}
655
656
} else {
656
657
DATEG (timezone_valid ) = 1 ;
@@ -683,7 +684,7 @@ static char* guess_timezone(const timelib_tzdb *tzdb)
683
684
}
684
685
685
686
if (!timelib_timezone_id_is_valid (DATEG (default_timezone ), tzdb )) {
686
- php_error_docref ( NULL , E_WARNING , "Invalid date.timezone value '%s', we selected the timezone 'UTC' for now. " , DATEG (default_timezone ));
687
+ zend_value_error ( "Invalid date.timezone value '%s'" , DATEG (default_timezone ));
687
688
return "UTC" ;
688
689
}
689
690
@@ -702,7 +703,7 @@ PHPAPI timelib_tzinfo *get_timezone_info(void)
702
703
tz = guess_timezone (DATE_TIMEZONEDB );
703
704
tzi = php_date_parse_tzfile (tz , DATE_TIMEZONEDB );
704
705
if (! tzi ) {
705
- php_error_docref (NULL , E_ERROR , "Timezone database is corrupt - this should *never* happen!" );
706
+ zend_throw_error (NULL , "Timezone database is corrupt - this should *never* happen!" );
706
707
}
707
708
return tzi ;
708
709
}
@@ -1099,8 +1100,8 @@ PHP_FUNCTION(idate)
1099
1100
ZEND_PARSE_PARAMETERS_END ();
1100
1101
1101
1102
if (ZSTR_LEN (format ) != 1 ) {
1102
- php_error_docref ( NULL , E_WARNING , "idate format is one char" );
1103
- RETURN_FALSE ;
1103
+ zend_value_error ( "idate format is one char" );
1104
+ return ;
1104
1105
}
1105
1106
1106
1107
if (ZEND_NUM_ARGS () == 1 ) {
@@ -1109,8 +1110,8 @@ PHP_FUNCTION(idate)
1109
1110
1110
1111
ret = php_idate (ZSTR_VAL (format )[0 ], ts , 0 );
1111
1112
if (ret == -1 ) {
1112
- php_error_docref ( NULL , E_WARNING , "Unrecognized date format token. " );
1113
- RETURN_FALSE ;
1113
+ zend_value_error ( "Unrecognized date format token" );
1114
+ return ;
1114
1115
}
1115
1116
RETURN_LONG (ret );
1116
1117
}
@@ -1897,7 +1898,7 @@ static int date_object_compare_date(zval *d1, zval *d2) /* {{{ */
1897
1898
o2 = Z_PHPDATE_P (d2 );
1898
1899
1899
1900
if (!o1 -> time || !o2 -> time ) {
1900
- php_error_docref (NULL , E_WARNING , "Trying to compare an incomplete DateTime or DateTimeImmutable object" );
1901
+ zend_throw_error (NULL , "Trying to compare an incomplete DateTime or DateTimeImmutable object" );
1901
1902
return 1 ;
1902
1903
}
1903
1904
if (!o1 -> time -> sse_uptodate ) {
@@ -2324,7 +2325,7 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
2324
2325
2325
2326
if (ctor && err && err -> error_count ) {
2326
2327
/* spit out the first library error message, at least */
2327
- php_error_docref (NULL , E_WARNING , "Failed to parse time string (%s) at position %d (%c): %s" , time_str ,
2328
+ zend_throw_error (NULL , "Failed to parse time string (%s) at position %d (%c): %s" , time_str ,
2328
2329
err -> error_messages [0 ].position , err -> error_messages [0 ].character , err -> error_messages [0 ].message );
2329
2330
}
2330
2331
if (err && err -> error_count ) {
@@ -2855,7 +2856,7 @@ static int php_date_modify(zval *object, char *modify, size_t modify_len) /* {{{
2855
2856
dateobj = Z_PHPDATE_P (object );
2856
2857
2857
2858
if (!(dateobj -> time )) {
2858
- php_error_docref (NULL, E_WARNING , "The DateTime object has not been correctly initialized by its constructor" );
2859
+ zend_throw_error (NULL, "The DateTime object has not been correctly initialized by its constructor" );
2859
2860
return 0 ;
2860
2861
}
2861
2862
@@ -2865,7 +2866,7 @@ static int php_date_modify(zval *object, char *modify, size_t modify_len) /* {{{
2865
2866
update_errors_warnings (err );
2866
2867
if (err && err -> error_count ) {
2867
2868
/* spit out the first library error message, at least */
2868
- php_error_docref (NULL , E_WARNING , "Failed to parse time string (%s) at position %d (%c): %s" , modify ,
2869
+ zend_throw_error (NULL , "Failed to parse time string (%s) at position %d (%c): %s" , modify ,
2869
2870
err -> error_messages [0 ].position , err -> error_messages [0 ].character , err -> error_messages [0 ].message );
2870
2871
timelib_time_dtor (tmp_time );
2871
2872
return 0 ;
@@ -3022,7 +3023,7 @@ static void php_date_sub(zval *object, zval *interval, zval *return_value) /* {{
3022
3023
DATE_CHECK_INITIALIZED (intobj -> initialized , DateInterval );
3023
3024
3024
3025
if (intobj -> diff -> have_special_relative ) {
3025
- php_error_docref (NULL , E_WARNING , "Only non-special relative time specifications are supported for subtraction" );
3026
+ zend_throw_error (NULL , "Only non-special relative time specifications are supported for subtraction" );
3026
3027
return ;
3027
3028
}
3028
3029
@@ -3474,14 +3475,14 @@ static int timezone_initialize(php_timezone_obj *tzobj, /*const*/ char *tz, size
3474
3475
char * orig_tz = tz ;
3475
3476
3476
3477
if (strlen (tz ) != tz_len ) {
3477
- php_error_docref ( NULL , E_WARNING , "Timezone must not contain null bytes" );
3478
+ zend_value_error ( "Timezone must not contain null bytes" );
3478
3479
efree (dummy_t );
3479
3480
return FAILURE ;
3480
3481
}
3481
3482
3482
3483
dummy_t -> z = timelib_parse_zone (& tz , & dst , dummy_t , & not_found , DATE_TIMEZONEDB , php_date_parse_tzfile_wrapper );
3483
3484
if (not_found ) {
3484
- php_error_docref ( NULL , E_WARNING , "Unknown or bad timezone (%s)" , orig_tz );
3485
+ zend_value_error ( "Unknown or bad timezone (%s)" , orig_tz );
3485
3486
efree (dummy_t );
3486
3487
return FAILURE ;
3487
3488
} else {
@@ -3792,7 +3793,7 @@ static int date_interval_initialize(timelib_rel_time **rt, /*const*/ char *forma
3792
3793
timelib_strtointerval (format , format_length , & b , & e , & p , & r , & errors );
3793
3794
3794
3795
if (errors -> error_count > 0 ) {
3795
- php_error_docref ( NULL , E_WARNING , "Unknown or bad format (%s)" , format );
3796
+ zend_value_error ( "Unknown or bad format (%s)" , format );
3796
3797
retval = FAILURE ;
3797
3798
} else {
3798
3799
if (p ) {
@@ -3805,7 +3806,7 @@ static int date_interval_initialize(timelib_rel_time **rt, /*const*/ char *forma
3805
3806
* rt = timelib_diff (b , e );
3806
3807
retval = SUCCESS ;
3807
3808
} else {
3808
- php_error_docref (NULL , E_WARNING , "Failed to parse interval (%s)" , format );
3809
+ zend_throw_error (NULL , "Failed to parse interval (%s)" , format );
3809
3810
retval = FAILURE ;
3810
3811
}
3811
3812
}
@@ -4097,7 +4098,7 @@ PHP_FUNCTION(date_interval_create_from_date_string)
4097
4098
time = timelib_strtotime (ZSTR_VAL (time_str ), ZSTR_LEN (time_str ), & err , DATE_TIMEZONEDB , php_date_parse_tzfile_wrapper );
4098
4099
4099
4100
if (err -> error_count > 0 ) {
4100
- php_error_docref ( NULL , E_WARNING , "Unknown or bad format (%s) at position %d (%c): %s" , ZSTR_VAL (time_str ),
4101
+ zend_value_error ( "Unknown or bad format (%s) at position %d (%c): %s" , ZSTR_VAL (time_str ),
4101
4102
err -> error_messages [0 ].position , err -> error_messages [0 ].character ? err -> error_messages [0 ].character : ' ' , err -> error_messages [0 ].message );
4102
4103
RETVAL_FALSE ;
4103
4104
goto cleanup ;
@@ -4215,7 +4216,7 @@ static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_
4215
4216
timelib_strtointerval (format , format_length , & b , & e , & p , & r , & errors );
4216
4217
4217
4218
if (errors -> error_count > 0 ) {
4218
- php_error_docref ( NULL , E_WARNING , "Unknown or bad format (%s)" , format );
4219
+ zend_value_error ( "Unknown or bad format (%s)" , format );
4219
4220
retval = FAILURE ;
4220
4221
} else {
4221
4222
* st = b ;
@@ -4246,7 +4247,7 @@ PHP_METHOD(DatePeriod, __construct)
4246
4247
if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "OOl|l" , & start , date_ce_interface , & interval , date_ce_interval , & recurrences , & options ) == FAILURE ) {
4247
4248
if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "OOO|l" , & start , date_ce_interface , & interval , date_ce_interval , & end , date_ce_interface , & options ) == FAILURE ) {
4248
4249
if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "s|l" , & isostr , & isostr_len , & options ) == FAILURE ) {
4249
- php_error_docref ( NULL , E_WARNING , "This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments." );
4250
+ zend_type_error ( "This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments." );
4250
4251
zend_restore_error_handling (& error_handling );
4251
4252
return ;
4252
4253
}
@@ -4259,13 +4260,16 @@ PHP_METHOD(DatePeriod, __construct)
4259
4260
if (isostr ) {
4260
4261
date_period_initialize (& (dpobj -> start ), & (dpobj -> end ), & (dpobj -> interval ), & recurrences , isostr , isostr_len );
4261
4262
if (dpobj -> start == NULL ) {
4262
- php_error_docref (NULL , E_WARNING , "The ISO interval '%s' did not contain a start date." , isostr );
4263
+ zend_value_error ("The ISO interval '%s' did not contain a start date." , isostr );
4264
+ return ;
4263
4265
}
4264
4266
if (dpobj -> interval == NULL ) {
4265
- php_error_docref (NULL , E_WARNING , "The ISO interval '%s' did not contain an interval." , isostr );
4267
+ zend_value_error ("The ISO interval '%s' did not contain an interval." , isostr );
4268
+ return ;
4266
4269
}
4267
4270
if (dpobj -> end == NULL && recurrences == 0 ) {
4268
- php_error_docref (NULL , E_WARNING , "The ISO interval '%s' did not contain an end date or a recurrence count." , isostr );
4271
+ zend_value_error ("The ISO interval '%s' did not contain an end date or a recurrence count." , isostr );
4272
+ return ;
4269
4273
}
4270
4274
4271
4275
if (dpobj -> start ) {
@@ -4304,7 +4308,8 @@ PHP_METHOD(DatePeriod, __construct)
4304
4308
}
4305
4309
4306
4310
if (dpobj -> end == NULL && recurrences < 1 ) {
4307
- php_error_docref (NULL , E_WARNING , "The recurrence count '%d' is invalid. Needs to be > 0" , (int ) recurrences );
4311
+ zend_value_error ("The recurrence count '%d' is invalid. Needs to be > 0" , (int ) recurrences );
4312
+ return ;
4308
4313
}
4309
4314
4310
4315
/* options */
@@ -4447,6 +4452,7 @@ PHP_FUNCTION(timezone_identifiers_list)
4447
4452
4448
4453
/* Extra validation */
4449
4454
if (what == PHP_DATE_TIMEZONE_PER_COUNTRY && option_len != 2 ) {
4455
+ /* Upgrade to warning/exception? */
4450
4456
php_error_docref (NULL , E_NOTICE , "A two-letter ISO 3166-1 compatible country code is expected" );
4451
4457
RETURN_FALSE ;
4452
4458
}
@@ -4596,16 +4602,15 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
4596
4602
case 6 :
4597
4603
break ;
4598
4604
default :
4599
- php_error_docref (NULL , E_WARNING , "invalid format" );
4600
- RETURN_FALSE ;
4601
- break ;
4605
+ zend_value_error ("Invalid format" );
4606
+ return ;
4602
4607
}
4603
4608
if (retformat != SUNFUNCS_RET_TIMESTAMP &&
4604
4609
retformat != SUNFUNCS_RET_STRING &&
4605
4610
retformat != SUNFUNCS_RET_DOUBLE )
4606
4611
{
4607
- php_error_docref ( NULL , E_WARNING , "Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE" );
4608
- RETURN_FALSE ;
4612
+ zend_value_error ( "Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE" );
4613
+ return ;
4609
4614
}
4610
4615
altitude = 90 - zenith ;
4611
4616
0 commit comments