浏览代码

merged branch drm/master (PR #1615)

Commits
-------

9714cfc Fixes fatal error when intl module is not installed.

Discussion
----------

Session instantiation breaks with Fatal error if intl module is not installed.

A check for class_exists in setPhpDefaultLocale() fixes this, though I got the feeling it should be resolved with a proxy or subscriber object; setPhpDefaultLocale feels like a hack now.

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

by stealth35 at 2011/07/10 06:32:43 -0700

Locale::setDefault don't throw any exception
Maybe just :

```php
if (class_exists('Locale', false)) {
    return \Locale::setDefault($this->locale);
} else {
    return false;
}
```
Fabien Potencier 14 年之前
父节点
当前提交
29460becde
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/Symfony/Component/HttpFoundation/Session.php

+ 6 - 2
src/Symfony/Component/HttpFoundation/Session.php

@@ -355,10 +355,14 @@ class Session implements \Serializable
 
     private function setPhpDefaultLocale($locale)
     {
+        // if either the class Locale doesn't exist, or an exception is thrown when
+        // setting the default locale, the intl module is not installed, and
+        // the call can be ignored:
         try {
-            \Locale::setDefault($this->locale);
+            if (class_exists('Locale', false)) {
+                \Locale::setDefault($locale);
+            }
         } catch (\Exception $e) {
-            // means that intl is not installed.
         }
     }
 }