mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
Merge branch 'PHP-7.3' into PHP-7.4
This commit is contained in:
commit
4a3f64dfef
@ -4646,6 +4646,10 @@ PHP_METHOD(DatePeriod, __construct)
|
||||
dpobj->end = clone;
|
||||
}
|
||||
}
|
||||
|
||||
if (dpobj->end == NULL && recurrences < 1) {
|
||||
php_error_docref(NULL, E_WARNING, "The recurrence count '%d' is invalid. Needs to be > 0", (int) recurrences);
|
||||
}
|
||||
|
||||
/* options */
|
||||
dpobj->include_start_date = !(options & PHP_DATE_PERIOD_EXCLUDE_START_DATE);
|
||||
|
@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
DatePeriod: Test wrong recurrence parameter on __construct
|
||||
--FILE--
|
||||
<?php
|
||||
try {
|
||||
new DatePeriod(new DateTime('yesterday'), new DateInterval('P1D'), 0);
|
||||
} catch (Exception $exception) {
|
||||
echo $exception->getMessage(), "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
new DatePeriod(new DateTime('yesterday'), new DateInterval('P1D'),-1);
|
||||
} catch (Exception $exception) {
|
||||
echo $exception->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
DatePeriod::__construct(): The recurrence count '0' is invalid. Needs to be > 0
|
||||
DatePeriod::__construct(): The recurrence count '-1' is invalid. Needs to be > 0
|
Loading…
Reference in New Issue
Block a user