merged branch nodrew/2.0 (PR #3625)

Commits
-------

8642473 Changed instances of \DateTimeZone::UTC to 'UTC' as the constant is not valid a produces this error when DateTimeZone is instantiated: DateTimeZone::__construct() [<a href='datetimezone.--construct'>datetimezone.--construct</a>]: Unknown or bad timezone (1024)

Discussion
----------

[Locale] DateTimeZone called incorrectly by default

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: no (there were two tests that were failing previously, that still fail)
Fixes the following tickets: none
Todo: none

While running, a warning throws every single time when the code

```php
new \DateTimeZone(\DateTimeZone::UTC);
```
is encountered. It is normally caught as a thrown exception and then corrected here:

```php
// src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php:442
        try {
            $this->dateTimeZone = new \DateTimeZone($timeZoneId);
        } catch (\Exception $e) {
            $this->dateTimeZone = new \DateTimeZone('UTC');
        }
```

However in my particular infrastructure, for whatever reason in production only, it causes an error to appear on shutdown in the logs. As ultimately the constant can NEVER pass, it should not be attempted with the constant. Instead, the correct 'UTC' should be passed in (as done in the catch statement).
This commit is contained in:
Fabien Potencier 2012-03-17 09:45:14 +01:00
commit 65a83dcba0
3 changed files with 3 additions and 3 deletions

View File

@ -39,7 +39,7 @@ class MonthChoiceList extends PaddedChoiceList
$pattern = $this->formatter->getPattern();
$timezone = $this->formatter->getTimezoneId();
$this->formatter->setTimezoneId(\DateTimeZone::UTC);
$this->formatter->setTimezoneId('UTC');
if (preg_match('/M+/', $pattern, $matches)) {
$this->formatter->setPattern($matches[0]);

View File

@ -57,7 +57,7 @@ class DateType extends AbstractType
\Locale::getDefault(),
$format,
\IntlDateFormatter::NONE,
\DateTimeZone::UTC,
'UTC',
\IntlDateFormatter::GREGORIAN,
$pattern
);

View File

@ -31,7 +31,7 @@ class MonthChoiceListTest extends \PHPUnit_Framework_TestCase
\Locale::getDefault(),
\IntlDateFormatter::SHORT,
\IntlDateFormatter::NONE,
\DateTimeZone::UTC
'UTC'
);
}