Ignore:
Timestamp:
2014/08/22 18:31:39 (10 years ago)
Author:
kimoto
Message:

#2609 モジュールのバグfix

XML_Util 1.2.3
Mobile_Detect 2.8.3
Cache_Lite 1.7.16
Archive_Tar 1.3.12

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/module/Cache/Lite.php

    r22587 r23600  
    248248     */ 
    249249    var $_errorHandlingAPIBreak = false; 
     250     
     251    var $_hashedDirectoryGroup = NULL; 
     252     
     253    var $_cacheFileMode = NULL; 
     254     
     255    var $_cacheFileGroup = NULL; 
    250256     
    251257    // --- Public methods --- 
     
    273279    *     'hashedDirectoryUmask' => umask for hashed directory structure (int), 
    274280    *     'errorHandlingAPIBreak' => API break for better error handling ? (boolean) 
     281    *     'hashedDirectoryGroup' => group of hashed directory structure (int | string) (see function chgrp) 
     282    *     'cacheFileMode' => filesystem mode of newly created cache files (int) 
     283    *     'cacheFileGroup' => group of newly created cache files (int | string) (see function chgrp) 
    275284    * ); 
    276285    *  
     
    307316    function setOption($name, $value)  
    308317    { 
    309         $availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode'); 
     318        $availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode', 'hashedDirectoryGroup', 'cacheFileMode', 'cacheFileGroup'); 
    310319        if (in_array($name, $availableOptions)) { 
    311320            $property = '_'.$name; 
     
    666675        return $result; 
    667676    } 
    668        
     677 
     678    /** 
     679    * Touch the cache file while are recreating it to avoid 
     680    * launch this task more then once when necessary 
     681    * When the cache recreated and Added in Cache Memory 
     682    * @return void 
     683    * @access private 
     684    */ 
     685    function _touchCacheFile(){ 
     686        if (file_exists($this->_file)) { 
     687            @touch($this->_file); 
     688        } 
     689    } 
    669690    /** 
    670691    * Add some date in the memory caching array 
     
    675696    function _memoryCacheAdd($data) 
    676697    { 
     698        $this->_touchCacheFile(); 
    677699        $this->_memoryCachingArray[$this->_file] = $data; 
    678700        if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { 
     
    776798                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/'; 
    777799                if (!(@is_dir($root))) { 
    778                     @mkdir($root, $this->_hashedDirectoryUmask); 
     800                    if (@mkdir($root)) 
     801                    { 
     802                        @chmod($root, $this->_hashedDirectoryUmask); 
     803                        if (! is_null($this->_hashedDirectoryGroup)) 
     804                            @chgrp($root, $this->_hashedDirectoryGroup); 
     805                    } 
    779806                } 
    780807            } 
    781808        } 
     809        // if both _cacheFileMode and _cacheFileGroup is null, then we don't need to call 
     810        // file_exists (see below: if ($is_newfile) ...) 
     811        $is_newfile = (! is_null($this->_cacheFileMode) || !is_null($this->_cacheFileGroup))  
     812            && ! @file_exists($this->_file); 
    782813        $fp = @fopen($this->_file, "wb"); 
    783814        if ($fp) { 
    784815            if ($this->_fileLocking) @flock($fp, LOCK_EX); 
     816            if ($is_newfile) 
     817            { 
     818                if (! is_null($this->_cacheFileMode)) 
     819                    @chmod($this->_file, $this->_cacheFileMode); 
     820                if (! is_null($this->_cacheFileGroup)) 
     821                    @chgrp($this->_file, $this->_cacheFileGroup); 
     822            } 
    785823            if ($this->_readControl) { 
    786824                @fwrite($fp, $this->_hash($data, $this->_readControlType), 32); 
Note: See TracChangeset for help on using the changeset viewer.