Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36bd06a

Browse files
bug #22996 [2.7][Form] Fix \IntlDateFormatter timezone parameter usage to bypass PHP bug #66323 (romainneutron)
This PR was merged into the 2.7 branch. Discussion ---------- [2.7][Form] Fix \IntlDateFormatter timezone parameter usage to bypass PHP bug #66323 | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A The issue is documented here. The current symfony code works when `intl.use_exception` is off. however, it's on on PHP 7+ and the issue is reproducible. See https://3v4l.org/PllP1 and https://3v4l.org/3XnKI Commits ------- f42c73f [Form] Fix \IntlDateFormatter timezone parameter usage to bypass PHP bug #66323
2 parents e33cdc2 + f42c73f commit 36bd06a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ protected function getIntlDateFormatter($ignoreTimezone = false)
163163
$dateFormat = $this->dateFormat;
164164
$timeFormat = $this->timeFormat;
165165
$timezone = $ignoreTimezone ? 'UTC' : $this->outputTimezone;
166+
if (class_exists('IntlTimeZone', false)) {
167+
// see https://bugs.php.net/bug.php?id=66323
168+
$timezone = \IntlTimeZone::createTimeZone($timezone);
169+
}
166170
$calendar = $this->calendar;
167171
$pattern = $this->pattern;
168172

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
7777
\Locale::getDefault(),
7878
$dateFormat,
7979
$timeFormat,
80-
null,
80+
// see https://bugs.php.net/bug.php?id=66323
81+
class_exists('IntlTimeZone', false) ? \IntlTimeZone::createDefault() : null,
8182
$calendar,
8283
$pattern
8384
);

0 commit comments

Comments
 (0)