com php-src: Produce a better exception message when IntlDateFormatter constructor fails.: ext/intl/dateformat/dateformat_create.c pp
ext/intl/tests/dateformat_invalid_timezone.phpt

From: Date: Sun, 25 Jun 2017 21:44:59 +0000
Subject: com php-src: Produce a better exception message when IntlDateFormatter constructor fails.: ext/intl/dateformat/dateformat_create.c pp
ext/intl/tests/dateformat_invalid_timezone.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-98225@lists.php.net to get a copy of this message
Commit: ecaf408d30af119c04c67bf99790655a1e818472 Author: Sara Golemon <pollita@php.net> Sun, 25 Jun 2017 17:44:59 -0400 Parents: e5741da85c72f963e9bdb47707d990cc6cd49ffc Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ecaf408d30af119c04c67bf99790655a1e818472 Log: Produce a better exception message when IntlDateFormatter constructor fails. Changed paths: M ext/intl/dateformat/dateformat_create.cpp A ext/intl/tests/dateformat_invalid_timezone.phpt Diff: diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp index 00a5cc5..e060711 100644 --- a/ext/intl/dateformat/dateformat_create.cpp +++ b/ext/intl/dateformat/dateformat_create.cpp @@ -216,7 +216,7 @@ U_CFUNC PHP_METHOD( IntlDateFormatter, __construct ) return_value = getThis(); if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1) == FAILURE) { if (!EG(exception)) { - zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); + zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(intl_error_get_message(NULL)), intl_error_get_code(NULL)); } } zend_restore_error_handling(&error_handling); diff --git a/ext/intl/tests/dateformat_invalid_timezone.phpt b/ext/intl/tests/dateformat_invalid_timezone.phpt new file mode 100644 index 0000000..5b54fa8 --- /dev/null +++ b/ext/intl/tests/dateformat_invalid_timezone.phpt @@ -0,0 +1,18 @@ +--TEST-- +IntlDateFormat constructor failure +--INI-- +date.timezone=Mars/Utopia_Planitia +--SKIPIF-- +<?php +extension_loaded('intl') || print 'skip'; +--FILE-- +<?php + +try { + new \IntlDateFormatter('en_US', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL); + echo "Wat?"; +} catch (\IntlException $e) { + echo $e->getMessage(); +} +--EXPECT-- +IntlDateFormatter::__construct(): Invalid date.timezone value 'Mars/Utopia_Planitia', we selected the timezone 'UTC' for now.

« previous php.cvs (#98225) next »