瀏覽代碼

[HttpFoundation] moved dir creation just before writing to disk

Fabien Potencier 14 年之前
父節點
當前提交
4f7484b946
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      src/Symfony/Component/HttpFoundation/SessionStorage/FilesystemSessionStorage.php

+ 4 - 4
src/Symfony/Component/HttpFoundation/SessionStorage/FilesystemSessionStorage.php

@@ -55,10 +55,6 @@ class FilesystemSessionStorage extends NativeSessionStorage
             session_id(hash('md5', uniqid(mt_rand(), true)));
         }
 
-        if (!is_dir($this->path)) {
-            mkdir($this->path, 0777, true);
-        }
-
         $file = $this->path.'/'.session_id().'.session';
 
         $this->data = file_exists($file) ? unserialize(file_get_contents($file)) : array();
@@ -92,6 +88,10 @@ class FilesystemSessionStorage extends NativeSessionStorage
     {
         $this->data[$key] = $data;
 
+        if (!is_dir($this->path)) {
+            mkdir($this->path, 0777, true);
+        }
+
         file_put_contents($this->path.'/'.session_id().'.session', serialize($this->data));
     }