mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Resolve discrepencies between second value yielded by gettimeofday and time, fixes #69044
This commit is contained in:
commit
fb95043acf
3 changed files with 30 additions and 9 deletions
3
NEWS
3
NEWS
|
@ -7,6 +7,9 @@ PHP NEWS
|
||||||
(Nikita)
|
(Nikita)
|
||||||
. Fixed bug #78154 (SEND_VAR_NO_REF does not always send reference). (Nikita)
|
. Fixed bug #78154 (SEND_VAR_NO_REF does not always send reference). (Nikita)
|
||||||
|
|
||||||
|
- Date:
|
||||||
|
. Fixed #69044 (discrepency between time and microtime). (krakjoe)
|
||||||
|
|
||||||
- Opcache:
|
- Opcache:
|
||||||
. Fixed bug #78106 (Path resolution fails if opcache disabled during request).
|
. Fixed bug #78106 (Path resolution fails if opcache disabled during request).
|
||||||
(Nikita)
|
(Nikita)
|
||||||
|
|
|
@ -60,6 +60,22 @@ static inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PHPAPI time_t php_time()
|
||||||
|
{
|
||||||
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
|
struct timeval tm;
|
||||||
|
|
||||||
|
if (UNEXPECTED(gettimeofday(&tm, NULL) != SUCCESS)) {
|
||||||
|
/* fallback, can't reasonably happen */
|
||||||
|
return time(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tm.tv_sec;
|
||||||
|
#else
|
||||||
|
return time(NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* {{{ arginfo */
|
/* {{{ arginfo */
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_date, 0, 0, 1)
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_date, 0, 0, 1)
|
||||||
ZEND_ARG_INFO(0, format)
|
ZEND_ARG_INFO(0, format)
|
||||||
|
@ -1263,7 +1279,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime)
|
||||||
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
|
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() == 1) {
|
if (ZEND_NUM_ARGS() == 1) {
|
||||||
ts = time(NULL);
|
ts = php_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_STR(php_format_date(ZSTR_VAL(format), ZSTR_LEN(format), ts, localtime));
|
RETURN_STR(php_format_date(ZSTR_VAL(format), ZSTR_LEN(format), ts, localtime));
|
||||||
|
@ -1428,7 +1444,7 @@ PHP_FUNCTION(idate)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() == 1) {
|
if (ZEND_NUM_ARGS() == 1) {
|
||||||
ts = time(NULL);
|
ts = php_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = php_idate(ZSTR_VAL(format)[0], ts, 0);
|
ret = php_idate(ZSTR_VAL(format)[0], ts, 0);
|
||||||
|
@ -1500,7 +1516,7 @@ PHP_FUNCTION(strtotime)
|
||||||
now->tz_info = tzi;
|
now->tz_info = tzi;
|
||||||
now->zone_type = TIMELIB_ZONETYPE_ID;
|
now->zone_type = TIMELIB_ZONETYPE_ID;
|
||||||
timelib_unixtime2local(now,
|
timelib_unixtime2local(now,
|
||||||
(ZEND_NUM_ARGS() == 2) ? (timelib_sll) preset_ts : (timelib_sll) time(NULL));
|
(ZEND_NUM_ARGS() == 2) ? (timelib_sll) preset_ts : (timelib_sll) php_time());
|
||||||
|
|
||||||
t = timelib_strtotime(ZSTR_VAL(times), ZSTR_LEN(times), &error,
|
t = timelib_strtotime(ZSTR_VAL(times), ZSTR_LEN(times), &error,
|
||||||
DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
|
DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
|
||||||
|
@ -1543,12 +1559,12 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
|
||||||
/* Initialize structure with current time */
|
/* Initialize structure with current time */
|
||||||
now = timelib_time_ctor();
|
now = timelib_time_ctor();
|
||||||
if (gmt) {
|
if (gmt) {
|
||||||
timelib_unixtime2gmt(now, (timelib_sll) time(NULL));
|
timelib_unixtime2gmt(now, (timelib_sll) php_time());
|
||||||
} else {
|
} else {
|
||||||
tzi = get_timezone_info();
|
tzi = get_timezone_info();
|
||||||
now->tz_info = tzi;
|
now->tz_info = tzi;
|
||||||
now->zone_type = TIMELIB_ZONETYPE_ID;
|
now->zone_type = TIMELIB_ZONETYPE_ID;
|
||||||
timelib_unixtime2local(now, (timelib_sll) time(NULL));
|
timelib_unixtime2local(now, (timelib_sll) php_time());
|
||||||
}
|
}
|
||||||
/* Fill in the new data */
|
/* Fill in the new data */
|
||||||
switch (ZEND_NUM_ARGS()) {
|
switch (ZEND_NUM_ARGS()) {
|
||||||
|
@ -1648,7 +1664,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
|
||||||
timelib_time_offset *offset = NULL;
|
timelib_time_offset *offset = NULL;
|
||||||
zend_string *buf;
|
zend_string *buf;
|
||||||
|
|
||||||
timestamp = (zend_long) time(NULL);
|
timestamp = (zend_long) php_time();
|
||||||
|
|
||||||
ZEND_PARSE_PARAMETERS_START(1, 2)
|
ZEND_PARSE_PARAMETERS_START(1, 2)
|
||||||
Z_PARAM_STR(format)
|
Z_PARAM_STR(format)
|
||||||
|
@ -1755,7 +1771,7 @@ PHP_FUNCTION(time)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_LONG((zend_long)time(NULL));
|
RETURN_LONG((zend_long)php_time());
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -1775,7 +1791,7 @@ PHP_FUNCTION(localtime)
|
||||||
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
|
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() == 0) {
|
if (ZEND_NUM_ARGS() == 0) {
|
||||||
timestamp = (zend_long) time(NULL);
|
timestamp = (zend_long) php_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
tzi = get_timezone_info();
|
tzi = get_timezone_info();
|
||||||
|
@ -1826,7 +1842,7 @@ PHP_FUNCTION(getdate)
|
||||||
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
|
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() == 0) {
|
if (ZEND_NUM_ARGS() == 0) {
|
||||||
timestamp = (zend_long) time(NULL);
|
timestamp = (zend_long) php_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
tzi = get_timezone_info();
|
tzi = get_timezone_info();
|
||||||
|
|
|
@ -197,6 +197,8 @@ ZEND_END_MODULE_GLOBALS(date)
|
||||||
|
|
||||||
#define DATEG(v) ZEND_MODULE_GLOBALS_ACCESSOR(date, v)
|
#define DATEG(v) ZEND_MODULE_GLOBALS_ACCESSOR(date, v)
|
||||||
|
|
||||||
|
PHPAPI time_t php_time();
|
||||||
|
|
||||||
/* Backwards compatibility wrapper */
|
/* Backwards compatibility wrapper */
|
||||||
PHPAPI zend_long php_parse_date(char *string, zend_long *now);
|
PHPAPI zend_long php_parse_date(char *string, zend_long *now);
|
||||||
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
|
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue