com php-src: Require at least one arg for mktime/gmmktime: UPGRADING ext/date/php_date.c ext/date/tests/gmmktime_basic.php t
ext/date/tests/mktime_error.phpt
| From: | Nikita Popov | Date: | Wed, 30 Jan 2019 12:13:47 +0000 |
| Subject: | com php-src: Require at least one arg for mktime/gmmktime: UPGRADING ext/date/php_date.c ext/date/tests/gmmktime_basic.php t ext/date/tests/mktime_error.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104400@lists.php.net to get a copy of this message | ||
Commit: 5a2787a02d56003e2e9731e2fad5b468180ec19a
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 30 Jan 2019 12:53:08 +0100
Parents: 94ae35c9fbc34b26c514b2ba097e021744100f28
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5a2787a02d56003e2e9731e2fad5b468180ec19a
Log:
Require at least one arg for mktime/gmmktime
Changed paths:
M UPGRADING
M ext/date/php_date.c
M ext/date/tests/gmmktime_basic.phpt
M ext/date/tests/mktime_error.phpt
Diff:
diff --git a/UPGRADING b/UPGRADING
index 45a1780...85da44d 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -34,6 +34,10 @@ PHP 8.0 UPGRADE NOTES
. Removed ability to unbind $this from closures that were created from a
method, using Closure::fromCallable() or ReflectionMethod::getClosure().
+- Date:
+ . mktime() and gmmktime() now require at least one argument. time() can be
+ used to get the current timestamp.
+
- Filter:
. The FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED flags for the
FILTER_VALIDATE_URL filter have been removed. The scheme and host are (and
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 9d6cb5f..2249adb 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -81,7 +81,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_strtotime, 0, 0, 1)
ZEND_ARG_INFO(0, now)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mktime, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_mktime, 0, 0, 1)
ZEND_ARG_INFO(0, hour)
ZEND_ARG_INFO(0, min)
ZEND_ARG_INFO(0, sec)
@@ -90,7 +90,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_mktime, 0, 0, 0)
ZEND_ARG_INFO(0, year)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_gmmktime, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_gmmktime, 0, 0, 1)
ZEND_ARG_INFO(0, hour)
ZEND_ARG_INFO(0, min)
ZEND_ARG_INFO(0, sec)
@@ -1531,9 +1531,9 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
zend_long ts, adjust_seconds = 0;
int error;
- ZEND_PARSE_PARAMETERS_START(0, 6)
- Z_PARAM_OPTIONAL
+ ZEND_PARSE_PARAMETERS_START(1, 6)
Z_PARAM_LONG(hou)
+ Z_PARAM_OPTIONAL
Z_PARAM_LONG(min)
Z_PARAM_LONG(sec)
Z_PARAM_LONG(mon)
@@ -1553,8 +1553,6 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
}
/* Fill in the new data */
switch (ZEND_NUM_ARGS()) {
- case 7:
- /* break intentionally missing */
case 6:
if (yea >= 0 && yea < 70) {
yea += 2000;
@@ -1578,8 +1576,7 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
case 1:
now->h = hou;
break;
- default:
- php_error_docref(NULL, E_DEPRECATED, "You should be using the time() function
instead");
+ EMPTY_SWITCH_DEFAULT_CASE()
}
/* Update the timestamp */
if (gmt) {
@@ -1601,7 +1598,7 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
}
/* }}} */
-/* {{{ proto int mktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+/* {{{ proto int mktime(int hour [, int min [, int sec [, int mon [, int day [, int year]]]]])
Get UNIX timestamp for a date */
PHP_FUNCTION(mktime)
{
@@ -1609,7 +1606,7 @@ PHP_FUNCTION(mktime)
}
/* }}} */
-/* {{{ proto int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+/* {{{ proto int gmmktime(int hour [, int min [, int sec [, int mon [, int day [, int year]]]]])
Get UNIX timestamp for a GMT date */
PHP_FUNCTION(gmmktime)
{
diff --git a/ext/date/tests/gmmktime_basic.phpt b/ext/date/tests/gmmktime_basic.phpt
index cdb44f0..c125e35 100644
--- a/ext/date/tests/gmmktime_basic.phpt
+++ b/ext/date/tests/gmmktime_basic.phpt
@@ -30,6 +30,6 @@ var_dump( gmmktime() );
*** Testing gmmktime() : basic functionality ***
int(1218182888)
-Deprecated: gmmktime(): You should be using the time() function instead in %s on line %d
-int(%d)
+Warning: gmmktime() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
===DONE===
diff --git a/ext/date/tests/mktime_error.phpt b/ext/date/tests/mktime_error.phpt
index a24d189..02e94a7 100644
--- a/ext/date/tests/mktime_error.phpt
+++ b/ext/date/tests/mktime_error.phpt
@@ -33,8 +33,8 @@ var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $extra_arg) );
-- Testing mktime() function with Zero arguments --
-Deprecated: mktime(): You should be using the time() function instead in %s on line %d
-int(%d)
+Warning: mktime() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
-- Testing mktime() function with more than expected no. of arguments --