-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.7][Form] Fix \IntlDateFormatter timezone parameter usage to bypass PHP bug #66323 #22996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.7][Form] Fix \IntlDateFormatter timezone parameter usage to bypass PHP bug #66323 #22996
Conversation
d234130
to
214fa1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -163,6 +163,10 @@ protected function getIntlDateFormatter($ignoreTimezone = false) | |||
$dateFormat = $this->dateFormat; | |||
$timeFormat = $this->timeFormat; | |||
$timezone = $ignoreTimezone ? 'UTC' : $this->outputTimezone; | |||
if (!defined('HHVM_VERSION') && PHP_VERSION_ID >= 50500) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this could enhance portability:
if (class_exists('IntlTimeZone', false)) {
$timezone = \IntlTimeZone::createTimeZone($timezone)
}
@@ -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 | |||
defined('HHVM_VERSION') || PHP_VERSION_ID < 50500 ? null : new \DateTimeZone(date_default_timezone_get()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class_exists('IntlTimeZone', false) ? \IntlTimeZone::createDefault() : null
214fa1b
to
f42c73f
Compare
PR updated, comments addressed |
Thank you @romainneutron. |
…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
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