Skip to content

Commit 7066f4e

Browse files
committed
re-establish lost exception classes, fixing tests and few nits
1 parent d75ea22 commit 7066f4e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

ext/date/php_date.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,12 +4907,11 @@ static bool date_period_init_finish(php_period_obj *dpobj, zend_long options, ze
49074907

49084908
if (dpobj->end == NULL && (recurrences < 1 || recurrences > max_recurrences)) {
49094909
zend_string *func = get_active_function_or_method_name();
4910-
zend_throw_exception_ex(NULL, 0, "%s(): Recurrence count must be greater or equal to 1 and lower than " ZEND_LONG_FMT, ZSTR_VAL(func), max_recurrences + 1);
4910+
zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): Recurrence count must be greater or equal to 1 and lower than " ZEND_LONG_FMT, ZSTR_VAL(func), max_recurrences + 1);
49114911
zend_string_release(func);
49124912
return false;
49134913
}
49144914

4915-
49164915
/* options */
49174916
dpobj->include_start_date = !(options & PHP_DATE_PERIOD_EXCLUDE_START_DATE);
49184917
dpobj->include_end_date = options & PHP_DATE_PERIOD_INCLUDE_END_DATE;
@@ -4922,7 +4921,7 @@ static bool date_period_init_finish(php_period_obj *dpobj, zend_long options, ze
49224921

49234922
if (UNEXPECTED(recurrences > max_recurrences)) {
49244923
zend_string *func = get_active_function_or_method_name();
4925-
zend_throw_exception_ex(NULL, 0, "%s(): Recurrence count must be greater or equal to 1 and lower than " ZEND_LONG_FMT " (including options)", ZSTR_VAL(func), max_recurrences + 1);
4924+
zend_throw_exception_ex(date_ce_date_malformed_string_exception, 0, "%s(): Recurrence count must be greater or equal to 1 and lower than " ZEND_LONG_FMT " (including options)", ZSTR_VAL(func), max_recurrences + 1);
49264925
zend_string_release(func);
49274926
return false;
49284927
}

ext/date/tests/date_period_bad_iso_format.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ DateMalformedPeriodStringException: DatePeriod::__construct(): ISO interval must
4545
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain a start date, "R4" given
4646
DateMalformedPeriodStringException: DatePeriod::__construct(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
4747
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
48-
Exception: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
49-
Exception: DatePeriod::createFromISO8601String(): Recurrence count must be greater or equal to 1 and lower than %d
48+
DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
49+
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): Recurrence count must be greater or equal to 1 and lower than %d
50+

ext/date/tests/gh14709.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ $interval = new DateInterval('P1M');
88
try {
99
new DatePeriod($start, $interval, 2147483640);
1010
} catch (Exception $e) {
11-
echo $e->getMessage() . PHP_EOL;
11+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
1212
}
1313

1414
try {
1515
new DatePeriod($start, $interval, 2147483639, DatePeriod::EXCLUDE_START_DATE | DatePeriod::INCLUDE_END_DATE);
1616
} catch (Exception $e) {
17-
echo $e->getMessage();
17+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
1818
}
1919
?>
2020
--EXPECTF--
21-
DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
22-
DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d (including options)
21+
DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
22+
DateMalformedStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d (including options)

0 commit comments

Comments
 (0)