Skip to content

Commit

Permalink
bug #22996 [2.7][Form] Fix \IntlDateFormatter timezone parameter usag…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
nicolas-grekas committed Jun 1, 2017
2 parents e33cdc2 + f42c73f commit 36bd06a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Expand Up @@ -163,6 +163,10 @@ protected function getIntlDateFormatter($ignoreTimezone = false)
$dateFormat = $this->dateFormat;
$timeFormat = $this->timeFormat;
$timezone = $ignoreTimezone ? 'UTC' : $this->outputTimezone;
if (class_exists('IntlTimeZone', false)) {
// see https://bugs.php.net/bug.php?id=66323
$timezone = \IntlTimeZone::createTimeZone($timezone);
}
$calendar = $this->calendar;
$pattern = $this->pattern;

Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Form/Extension/Core/Type/DateType.php
Expand Up @@ -77,7 +77,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
\Locale::getDefault(),
$dateFormat,
$timeFormat,
null,
// see https://bugs.php.net/bug.php?id=66323
class_exists('IntlTimeZone', false) ? \IntlTimeZone::createDefault() : null,
$calendar,
$pattern
);
Expand Down

0 comments on commit 36bd06a

Please sign in to comment.