com php-src: Fix #67976: cal_days_month() fails for final month of the French calendar: NEWS ext /calendar/calendar.c ext/calendar/tests/bug67976
.phpt

From: Date: Thu, 28 Jul 2016 17:13:58 +0000
Subject: com php-src: Fix #67976: cal_days_month() fails for final month of the French calendar: NEWS ext /calendar/calendar.c ext/calendar/tests/bug67976
.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-93464@lists.php.net to get a copy of this message
Commit: 7ab39e2faef499c8a1857205fa332d2e38a0a584 Author: Christoph M. Becker <cmb@php.net> Thu, 28 Jul 2016 19:13:58 +0200 Parents: ced2a80e6f6f023ab732d10076c89d177403a7fb Branches: PHP-5.6 PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7ab39e2faef499c8a1857205fa332d2e38a0a584 Log: Fix #67976: cal_days_month() fails for final month of the French calendar The French calendar ends on 0014-13-05, so trying to calculate the Julian day of 0015-01-01 fails. We cater to that by returning the hard-coded value. Bugs: https://bugs.php.net/67976 Changed paths: M NEWS M ext/calendar/calendar.c A ext/calendar/tests/bug67976.phpt Diff: diff --git a/NEWS b/NEWS index b03e691..98e9d42 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,10 @@ PHP NEWS . Fixed bug #72641 (phpize (on Windows) ignores PHP_PREFIX). (Yuji Uchiyama) +- Calendar: + .. Fixed bug #67976 (cal_days_month() fails for final month of the French + calendar). (cmb) + - Curl: . Fixed bug #71144 (Segmentation fault when using cURL with ZTS). (maroszek at gmx dot net) diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c index 74478e8..1f92b9f 100644 --- a/ext/calendar/calendar.c +++ b/ext/calendar/calendar.c @@ -359,6 +359,10 @@ PHP_FUNCTION(cal_days_in_month) } else { sdn_next = calendar->to_jd(year + 1, 1, 1); + if (cal == CAL_FRENCH && sdn_next == 0) { + /* The French calendar ends on 0014-13-05. */ + sdn_next = 2380953; + } } } diff --git a/ext/calendar/tests/bug67976.phpt b/ext/calendar/tests/bug67976.phpt new file mode 100644 index 0000000..74e0bc8 --- /dev/null +++ b/ext/calendar/tests/bug67976.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #67976 (cal_days_month() fails for final month of the French calendar) +--SKIPIF-- +<?php +if (!extension_loaded('calendar')) die('skip ext/calendar required'); +?> +--FILE-- +<?php +var_dump(cal_days_in_month(CAL_FRENCH, 13, 14)); +?> +--EXPECT-- +int(5)

« previous php.cvs (#93464) next »