Browse Source

Added check to save() method to ensure any octal presented as a string is converted to a decimal (otherwise left untouched)

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19865 44c647ce-9c0f-0410-b52a-842ac1e357ba
padraic 16 years ago
parent
commit
6b79310a9c
1 changed files with 16 additions and 1 deletions
  1. 16 1
      library/Zend/Cache/Backend/Static.php

+ 16 - 1
library/Zend/Cache/Backend/Static.php

@@ -189,7 +189,7 @@ class Zend_Cache_Backend_Static
 
         $pathName = $this->_options['public_dir'] . dirname($id);
         if (!file_exists($pathName)) {
-            mkdir($pathName, $this->_options['cache_file_umask'], true);
+            mkdir($pathName, $this->_octdec($this->_options['cache_file_umask']), true);
         }
 
         if (is_null($id) || strlen($id) == 0) {
@@ -456,4 +456,19 @@ class Zend_Cache_Backend_Static
             Zend_Cache::throwException("Invalid id or tag '$string' : must be a valid URL path");
         }
     }
+    
+    /**
+     * Detect an octal string and return its octal value for file permission ops
+     * otherwise return the non-string (assumed octal or decimal int already)
+     *
+     * @param $val The potential octal in need of conversion
+     * @return int
+     */
+    protected function _octdec($val)
+    {
+        if (decoct(octdec($val)) == $val && is_string($val)) {
+            return octdec($val);
+        }
+        return $val;
+    }
 }