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
This commit is contained in:
Nicolas Grekas 2017-06-01 14:45:44 +02:00
commit 36bd06a152
2 changed files with 6 additions and 1 deletions

View File

@ -163,6 +163,10 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
$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;

View File

@ -77,7 +77,8 @@ class DateType extends AbstractType
\Locale::getDefault(),
$dateFormat,
$timeFormat,
null,
// see https://bugs.php.net/bug.php?id=66323
class_exists('IntlTimeZone', false) ? \IntlTimeZone::createDefault() : null,
$calendar,
$pattern
);