2
0
Просмотр исходного кода

ZF-12047:
- renamed 'hashed_directory_umask' to 'hashed_directory_perm'
- renamed 'cache_file_umask' to 'cache_file_perm'

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24677 44c647ce-9c0f-0410-b52a-842ac1e357ba

mabe 14 лет назад
Родитель
Сommit
a615617759

+ 12 - 0
README.txt

@@ -17,6 +17,18 @@ A detailed list of all features and bug fixes in this release may be found at:
 
 http://framework.zend.com/changelog/
 
+MIGRATION NOTES
+---------------
+
+* Zend_Cache_Backend_File
+  * renamed options, old names still exists but triggers an E_USER_NOTICE error
+    * 'hashed_directory_umask' to 'hashed_directory_perm'
+    * 'cache_file_umask' to 'cache_file_perm'
+
+A detailed list of migration notes may be found at:
+
+http://framework.zend.com/manual/en/migration.html
+
 SYSTEM REQUIREMENTS
 -------------------
 

+ 9 - 2
documentation/manual/en/module_specs/Zend_Cache-Backends.xml

@@ -92,10 +92,10 @@
                     </row>
 
                     <row>
-                        <entry><emphasis>hashed_directory_umask</emphasis></entry>
+                        <entry><emphasis>hashed_directory_perm</emphasis></entry>
                         <entry><type>Integer</type></entry>
                         <entry>0700</entry>
-                        <entry>Umask for the hashed directory structure</entry>
+                        <entry>Permissins for the hashed directory structure</entry>
                     </row>
 
                     <row>
@@ -117,6 +117,13 @@
                         <entry>0600</entry>
                         <entry>umask for cache files</entry>
                     </row>
+                    
+                    <row>
+                        <entry><emphasis>cache_file_perm</emphasis></entry>
+                        <entry><type>Integer</type></entry>
+                        <entry>0600</entry>
+                        <entry>Permissions for cache files</entry>
+                    </row>
 
                     <row>
                         <entry><emphasis>metatadatas_array_max_size</emphasis></entry>

+ 35 - 11
library/Zend/Cache/Backend/File.php

@@ -71,7 +71,11 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
      * for you. Maybe, 1 or 2 is a good start.
      *
      * =====> (int) hashed_directory_umask :
-     * - Umask for hashed directory structure
+     * - deprecated
+     * - Permissions for hashed directory structure
+     *
+     * =====> (int) hashed_directory_perm :
+     * - Permissions for hashed directory structure
      *
      * =====> (string) file_name_prefix :
      * - prefix for cache files
@@ -79,7 +83,11 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
      *   (like /tmp) can cause disasters when cleaning the cache
      *
      * =====> (int) cache_file_umask :
-     * - Umask for cache files
+     * - deprecated
+     * - Permissions for cache files
+     *
+     * =====> (int) cache_file_perm :
+     * - Permissions for cache files
      *
      * =====> (int) metatadatas_array_max_size :
      * - max size for the metadatas array (don't change this value unless you
@@ -93,9 +101,9 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
         'read_control' => true,
         'read_control_type' => 'crc32',
         'hashed_directory_level' => 0,
-        'hashed_directory_umask' => 0700,
+        'hashed_directory_perm' => 0700,
         'file_name_prefix' => 'zend_cache',
-        'cache_file_umask' => 0600,
+        'cache_file_perm' => 0600,
         'metadatas_array_max_size' => 100
     );
 
@@ -130,13 +138,29 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
         if ($this->_options['metadatas_array_max_size'] < 10) {
             Zend_Cache::throwException('Invalid metadatas_array_max_size, must be > 10');
         }
-        if (isset($options['hashed_directory_umask']) && is_string($options['hashed_directory_umask'])) {
+
+        if (isset($options['hashed_directory_umask'])) {
+            // See #ZF-12047
+            trigger_error("'hashed_directory_umask' is deprecated -> please use 'hashed_directory_perm' instead", E_USER_NOTICE);
+            if (!isset($options['hashed_directory_perm'])) {
+                $options['hashed_directory_perm'] = $options['hashed_directory_umask'];
+            }
+        }
+        if (isset($options['hashed_directory_perm']) && is_string($options['hashed_directory_perm'])) {
             // See #ZF-4422
-            $this->_options['hashed_directory_umask'] = octdec($this->_options['hashed_directory_umask']);
+            $this->_options['hashed_directory_perm'] = octdec($this->_options['hashed_directory_perm']);
+        }
+
+        if (isset($options['cache_file_umask'])) {
+            // See #ZF-12047
+            trigger_error("'cache_file_umask' is deprecated -> please use 'cache_file_perm' instead", E_USER_NOTICE);
+            if (!isset($options['cache_file_perm'])) {
+                $options['cache_file_perm'] = $options['cache_file_umask'];
+            }
         }
-        if (isset($options['cache_file_umask']) && is_string($options['cache_file_umask'])) {
+        if (isset($options['cache_file_perm']) && is_string($options['cache_file_perm'])) {
             // See #ZF-4422
-            $this->_options['cache_file_umask'] = octdec($this->_options['cache_file_umask']);
+            $this->_options['cache_file_perm'] = octdec($this->_options['cache_file_perm']);
         }
     }
 
@@ -919,8 +943,8 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
         $partsArray = $this->_path($id, true);
         foreach ($partsArray as $part) {
             if (!is_dir($part)) {
-                @mkdir($part, $this->_options['hashed_directory_umask']);
-                @chmod($part, $this->_options['hashed_directory_umask']); // see #ZF-320 (this line is required in some configurations)
+                @mkdir($part, $this->_options['hashed_directory_perm']);
+                @chmod($part, $this->_options['hashed_directory_perm']); // see #ZF-320 (this line is required in some configurations)
             }
         }
         return true;
@@ -988,7 +1012,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
             }
             @fclose($f);
         }
-        @chmod($file, $this->_options['cache_file_umask']);
+        @chmod($file, $this->_options['cache_file_perm']);
         return $result;
     }
 

+ 34 - 2
tests/Zend/Cache/FileBackendTest.php

@@ -76,6 +76,40 @@ class Zend_Cache_FileBackendTest extends Zend_Cache_CommonExtendedBackendTest {
         unset($this->_instance);
     }
 
+    public function testSetDeprecatedHashedDirectoryUmask()
+    {
+        try {
+            $cache = new Zend_Cache_Backend_File(array(
+                'cache_dir'              => $this->_cache_dir,
+                'hashed_directory_umask' => 0700,
+            ));
+            $this->fail("Missing expected E_USER_NOTICE error");
+        } catch (PHPUnit_Framework_Error $e) {
+            if ($e->getCode() != E_USER_NOTICE) {
+                throw $e;
+            }
+
+            $this->assertContains('hashed_directory_umask', $e->getMessage());
+        }
+    }
+
+    public function testSetDeprecatedCacheFileUmask()
+    {
+        try {
+            $cache = new Zend_Cache_Backend_File(array(
+                    'cache_dir'        => $this->_cache_dir,
+                    'cache_file_umask' => 0700,
+            ));
+            $this->fail("Missing expected E_USER_NOTICE error");
+        } catch (PHPUnit_Framework_Error $e) {
+            if ($e->getCode() != E_USER_NOTICE) {
+                throw $e;
+            }
+
+            $this->assertContains('cache_file_umask', $e->getMessage());
+        }
+    }
+
     public function testConstructorCorrectCall()
     {
         $test = new Zend_Cache_Backend_File(array());
@@ -122,5 +156,3 @@ class Zend_Cache_FileBackendTest extends Zend_Cache_CommonExtendedBackendTest {
     }
 
 }
-
-