Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merged branch LawnGnome/PHP-5.5-compat (PR #6647)

This PR was merged into the 2.1 branch.

Commits
-------

4991607 Fix version_compare() calls for PHP 5.5.
34def9f Handle the deprecation of IntlDateFormatter::setTimeZoneId() in PHP 5.5.

Discussion
----------

[Form] [Locale] PHP 5.5 compatibility fixes

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: N/A
Todo: None
License of the code: MIT
Documentation PR: N/A

IntlDateFormatter::setTimeZoneId() is deprecated in PHP 5.5, which results in E_DEPRECATED errors when using the date form type. This PR works around that.

Furthermore, the version_compare() tests used in locale to detect PHP 5.5 are broken with snapshot and Git builds of PHP. I've also committed a fix for those tests in this PR.

---------------------------------------------------------------------------

by stof at 2013-01-10T08:24:15Z

shouldn't it even be done in 2.0 as it is a bugfix ?

---------------------------------------------------------------------------

by LawnGnome at 2013-01-11T00:49:11Z

Possibly — I don't know enough about Symfony's release management to know whether this is appropriate for 2.0, and I was mostly scratching my own itch, honestly.

---------------------------------------------------------------------------

by stof at 2013-01-11T01:51:35Z

well, it is a bugfix and 2.0 is also impacted, so it should be done in it.

---------------------------------------------------------------------------

by LawnGnome at 2013-01-11T02:52:21Z

The diff for 2.0 looks like it'll be just the StubIntlDateFormatter.php changes — the deprecated method isn't called in DateType on that branch, and there aren't any StubIntlDateFormatter tests on 2.0. How do you want that submitted — as a separate PR against 2.0?

---------------------------------------------------------------------------

by fabpot at 2013-01-11T07:20:18Z

@LawnGnome A separate pull request would be good. Thanks.

---------------------------------------------------------------------------

by LawnGnome at 2013-01-11T08:29:48Z

2.0 PR added as #6699.
  • Loading branch information...
commit 36f95a1fe529b80794154f0778d1e8e9147eb45d 2 parents 060cfed + 7593226
@fabpot fabpot authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 Extension/Core/Type/DateType.php
View
12 Extension/Core/Type/DateType.php
@@ -263,7 +263,11 @@ private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $
$pattern = $formatter->getPattern();
$timezone = $formatter->getTimezoneId();
- $formatter->setTimezoneId(\DateTimeZone::UTC);
+ if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
+ $formatter->setTimeZone(\DateTimeZone::UTC);
+ } else {
+ $formatter->setTimeZoneId(\DateTimeZone::UTC);
+ }
if (preg_match($regex, $pattern, $matches)) {
$formatter->setPattern($matches[0]);
@@ -277,7 +281,11 @@ private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $
$formatter->setPattern($pattern);
}
- $formatter->setTimezoneId($timezone);
+ if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
+ $formatter->setTimeZone($timezone);
+ } else {
+ $formatter->setTimeZoneId($timezone);
+ }
return $timestamps;
}
Please sign in to comment.
Something went wrong with that request. Please try again.