com php-src: Provide a specific error message if date.timezone value is invalid.: ext/date/php_date.c ext/date/tests/date_defau lt_timezone_get-4.phpt
| From: | Xinchen Hui | Date: | Tue, 11 Sep 2012 09:45:09 +0000 |
| Subject: | com php-src: Provide a specific error message if date.timezone value is invalid.: ext/date/php_date.c ext/date/tests/date_defau lt_timezone_get-4.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-70148@lists.php.net to get a copy of this message | ||
Commit: e06c47ca2ab482ab5e6ba47a9249a9b9417cb1b4
Author: Simon Welsh <simon@simon.geek.nz> Tue, 11 Sep 2012 21:14:51 +1200
Parents: 328a3d9f1384d3555833345dbe879e4d99922a35
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e06c47ca2ab482ab5e6ba47a9249a9b9417cb1b4
Log:
Provide a specific error message if date.timezone value is invalid.
Changed paths:
M ext/date/php_date..c
A ext/date/tests/date_default_timezone_get-4.phpt
Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 7c4e782..eac6ca5 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -862,9 +862,14 @@ static char* guess_timezone(const timelib_tzdb *tzdb TSRMLS_DC)
}
} else if (*DATEG(default_timezone) &&
timelib_timezone_id_is_valid(DATEG(default_timezone), tzdb)) {
return DATEG(default_timezone);
+ } else if (*DATEG(default_timezone)) {
+ /* Invalid date.timezone value */
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "date.timezone value '%s' is invalid.
We selected the timezone 'UTC' for now.", DATEG(default_timezone));
+ } else {
+ /* No date.timezone value */
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, DATE_TZ_ERRMSG "We selected the timezone
'UTC' for now, but please set date.timezone to select your timezone.");
}
/* Fallback to UTC */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, DATE_TZ_ERRMSG "We selected the timezone
'UTC' for now, but please set date.timezone to select your timezone.");
return "UTC";
}
diff --git a/ext/date/tests/date_default_timezone_get-4.phpt
b/ext/date/tests/date_default_timezone_get-4.phpt
new file mode 100644
index 0000000..e76d4e3
--- /dev/null
+++ b/ext/date/tests/date_default_timezone_get-4.phpt
@@ -0,0 +1,11 @@
+--TEST--
+date_default_timezone_get() function [4]
+--INI--
+date.timezone=Incorrect/Zone
+--FILE--
+<?php
+ echo date_default_timezone_get(), "\n";
+?>
+--EXPECTF--
+Warning: date_default_timezone_get(): date.timezone value 'Incorrect/Zone' is invalid. We
selected the timezone 'UTC' for now. in %sdate_default_timezone_get-4.php on line %d
+UTC