Skip to content

Commit b22caa8

Browse files
committed
Remove useless date warning
1 parent ffe4739 commit b22caa8

4 files changed

Lines changed: 5 additions & 18 deletions

File tree

ext/date/php_date.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -827,13 +827,6 @@ PHP_RSHUTDOWN_FUNCTION(date)
827827
*/
828828
#define DATE_FORMAT_COOKIE "l, d-M-Y H:i:s T"
829829

830-
#define DATE_TZ_ERRMSG \
831-
"It is not safe to rely on the system's timezone settings. You are " \
832-
"*required* to use the date.timezone setting or the " \
833-
"date_default_timezone_set() function. In case you used any of those " \
834-
"methods and you are still getting this warning, you most likely " \
835-
"misspelled the timezone identifier. "
836-
837830
#define SUNFUNCS_RET_TIMESTAMP 0
838831
#define SUNFUNCS_RET_STRING 1
839832
#define SUNFUNCS_RET_DOUBLE 2
@@ -954,7 +947,9 @@ static PHP_INI_MH(OnUpdate_date_timezone)
954947
DATEG(timezone_valid) = 0;
955948
if (stage == PHP_INI_STAGE_RUNTIME) {
956949
if (!timelib_timezone_id_is_valid(DATEG(default_timezone), DATE_TIMEZONEDB)) {
957-
php_error_docref(NULL, E_WARNING, DATE_TZ_ERRMSG);
950+
if (DATEG(default_timezone) && *DATEG(default_timezone)) {
951+
php_error_docref(NULL, E_WARNING, "Invalid date.timezone value '%s', we selected the timezone 'UTC' for now.", DATEG(default_timezone));
952+
}
958953
} else {
959954
DATEG(timezone_valid) = 1;
960955
}
@@ -994,7 +989,6 @@ static char* guess_timezone(const timelib_tzdb *tzdb)
994989
return DATEG(default_timezone);
995990
}
996991
/* Fallback to UTC */
997-
php_error_docref(NULL, E_WARNING, DATE_TZ_ERRMSG "We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.");
998992
return "UTC";
999993
}
1000994

ext/date/tests/date_default_timezone_get-1.phpt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ date.timezone=
1212
echo date_default_timezone_get(), "\n";
1313
echo date('e'), "\n";
1414
?>
15-
--EXPECTF--
16-
Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in %sdate_default_timezone_get-1.php on line 3
15+
--EXPECT--
1716
UTC
18-
19-
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in %sdate_default_timezone_get-1.php on line 4
2017
UTC

ext/date/tests/date_default_timezone_get-2.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ date.timezone=
1212
echo date_default_timezone_get(), "\n";
1313
?>
1414
--EXPECTF--
15-
Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in %sdate_default_timezone_get-2.php on line 3
1615
UTC

ext/date/tests/date_default_timezone_set-1.phpt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ date.timezone=
2121
echo date(DATE_ISO8601, $date3), "\n";
2222
echo date(DATE_ISO8601, $date4), "\n";
2323
?>
24-
--EXPECTF--
25-
Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in %sdate_default_timezone_set-1.php on line 3
26-
27-
Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in %sdate_default_timezone_set-1.php on line 4
24+
--EXPECT--
2825
America/Indiana/Knox
2926
2005-01-12T03:00:00-0500
3027
2005-07-12T03:00:00-0500

0 commit comments

Comments
 (0)