Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitebf967d

Browse files
committed
[Form] Check if IntlDateFormatter constructor returned a valid object before using it
1 parent37931f4 commitebf967d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

‎src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ public function reverseTransform($value)
152152
* Returns a preconfigured IntlDateFormatter instance
153153
*
154154
* @return \IntlDateFormatter
155+
*
156+
* @throws TransformationFailedException in case the date formatter can not be constructed.
155157
*/
156158
protectedfunctiongetIntlDateFormatter()
157159
{
@@ -162,6 +164,12 @@ protected function getIntlDateFormatter()
162164
$pattern =$this->pattern;
163165

164166
$intlDateFormatter =new \IntlDateFormatter(\Locale::getDefault(),$dateFormat,$timeFormat,$timezone,$calendar,$pattern);
167+
168+
// new \intlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/bug.php?id=66323
169+
if (!$intlDateFormatter) {
170+
thrownewTransformationFailedException(intl_get_error_message(),intl_get_error_code());
171+
}
172+
165173
$intlDateFormatter->setLenient(false);
166174

167175
return$intlDateFormatter;

‎src/Symfony/Component/Form/Extension/Core/Type/DateType.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
7777
$calendar,
7878
$pattern
7979
);
80+
81+
// new \intlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/bug.php?id=66323
82+
if (!$formatter) {
83+
thrownewInvalidOptionsException(intl_get_error_message(),intl_get_error_code());
84+
}
85+
8086
$formatter->setLenient(false);
8187

8288
if ('choice' ===$options['widget']) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp