Skip to content

Commit 66cc07d

Browse files
committed
Revert idate() changes
1 parent 27e14c9 commit 66cc07d

File tree

4 files changed

+27
-40
lines changed

4 files changed

+27
-40
lines changed

ext/date/php_date.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,8 @@ PHP_FUNCTION(idate)
951951
ZEND_PARSE_PARAMETERS_END();
952952

953953
if (ZSTR_LEN(format) != 1) {
954-
zend_argument_value_error(1, "must be one character");
955-
RETURN_THROWS();
954+
php_error_docref(NULL, E_WARNING, "idate format is one char");
955+
RETURN_FALSE;
956956
}
957957

958958
if (ts_is_null) {
@@ -961,8 +961,8 @@ PHP_FUNCTION(idate)
961961

962962
ret = php_idate(ZSTR_VAL(format)[0], ts, 0);
963963
if (ret == -1) {
964-
zend_argument_value_error(1, "must be a valid date format token");
965-
RETURN_THROWS();
964+
php_error_docref(NULL, E_WARNING, "Unrecognized date format token");
965+
RETURN_FALSE;
966966
}
967967
RETURN_LONG(ret);
968968
}

ext/date/php_date.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function strtotime(string $datetime, ?int $baseTimestamp = null): int|false {}
66

77
function date(string $format, ?int $timestamp = null): string {}
88

9-
function idate(string $format, ?int $timestamp = null): int {}
9+
function idate(string $format, ?int $timestamp = null): int|false {}
1010

1111
function gmdate(string $format, ?int $timestamp = null): string {}
1212

ext/date/php_date_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: eae561b0424a4837d35239b66be8c545d7ac2b04 */
2+
* Stub hash: cb1532309655d85eb2644cdcfbf23063dfa1ddaf */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtotime, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0)
@@ -11,7 +11,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date, 0, 1, IS_STRING, 0)
1111
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestamp, IS_LONG, 1, "null")
1212
ZEND_END_ARG_INFO()
1313

14-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_idate, 0, 1, IS_LONG, 0)
14+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_idate, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
1515
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
1616
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestamp, IS_LONG, 1, "null")
1717
ZEND_END_ARG_INFO()

ext/date/tests/005.phpt

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,29 @@ date_default_timezone_set('UTC');
66

77
$t = mktime(0,0,0, 6, 27, 2006);
88

9-
try {
10-
var_dump(idate(1,1));
11-
} catch (\ValueError $e) {
12-
echo $e->getMessage() . \PHP_EOL;
13-
}
14-
try {
15-
var_dump(idate(""));
16-
} catch (\ValueError $e) {
17-
echo $e->getMessage() . \PHP_EOL;
18-
}
19-
try {
20-
var_dump(idate(0));
21-
} catch (\ValueError $e) {
22-
echo $e->getMessage() . \PHP_EOL;
23-
}
24-
9+
var_dump(idate(1,1));
10+
var_dump(idate(""));
11+
var_dump(idate(0));
2512
var_dump(idate("B", $t));
26-
27-
try {
28-
var_dump(idate("[", $t));
29-
} catch (\ValueError $e) {
30-
echo $e->getMessage() . \PHP_EOL;
31-
}
32-
try {
33-
var_dump(idate("'"));
34-
} catch (\ValueError $e) {
35-
echo $e->getMessage() . \PHP_EOL;
36-
}
13+
var_dump(idate("[", $t));
14+
var_dump(idate("'"));
3715

3816
echo "Done\n";
3917
?>
40-
--EXPECT--
41-
idate(): Argument #1 ($format) must be a valid date format token
42-
idate(): Argument #1 ($format) must be one character
43-
idate(): Argument #1 ($format) must be a valid date format token
18+
--EXPECTF--
19+
Warning: idate(): Unrecognized date format token in %s on line %d
20+
bool(false)
21+
22+
Warning: idate(): idate format is one char in %s on line %d
23+
bool(false)
24+
25+
Warning: idate(): Unrecognized date format token in %s on line %d
26+
bool(false)
4427
int(41)
45-
idate(): Argument #1 ($format) must be a valid date format token
46-
idate(): Argument #1 ($format) must be a valid date format token
28+
29+
Warning: idate(): Unrecognized date format token in %s on line %d
30+
bool(false)
31+
32+
Warning: idate(): Unrecognized date format token in %s on line %d
33+
bool(false)
4734
Done

0 commit comments

Comments
 (0)