fixed bug #3667: Having many pages crashes DB in getPagePermsClause
authorsteffenk <steffenk@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 15 Jun 2009 09:04:55 +0000 (09:04 +0000)
committersteffenk <steffenk@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 15 Jun 2009 09:04:55 +0000 (09:04 +0000)
created new filecache for result of tx_beacl_userAuthGroup::getPagePermsClause

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/be_acl/trunk@21378 735d13b6-9817-0410-8766-e36946ffe9aa

ext_emconf.php
ext_localconf.php
res/class.tx_beacl_userauthgroup.php

index 975024a..5d412c5 100644 (file)
@@ -15,7 +15,7 @@ $EM_CONF[$_EXTKEY] = array(
        'description' => 'Backend Access Control Lists',
        'category' => 'be',
        'shy' => 0,
-       'version' => '1.4.0',
+       'version' => '1.4.1',
        'dependencies' => '',
        'conflicts' => '',
        'priority' => '',
@@ -23,7 +23,7 @@ $EM_CONF[$_EXTKEY] = array(
        'module' => '',
        'state' => 'stable',
        'uploadfolder' => 0,
-       'createDirs' => '',
+       'createDirs' => 'typo3temp/beacl_cache',
        'modify_tables' => '',
        'clearcacheonload' => 0,
        'lockType' => '',
index ae385f4..fb67b16 100644 (file)
@@ -14,4 +14,7 @@ $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getPagePe
 
 $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/web/perm/index.php'] = t3lib_extMgm::extPath('be_acl').'res/class.ux_sc_mod_web_perm_index.php';
 
+// Hook for clear cache
+$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'][$_EXTKEY] = 'EXT:be_acl/res/class.tx_beacl_userauthgroup.php:tx_beacl_userAuthGroup->clearCache';
+
 ?>
\ No newline at end of file
index 94b0b4a..b9d662a 100644 (file)
@@ -100,16 +100,12 @@ class tx_beacl_userAuthGroup {
         */
 
        function getPagePermsClause($params, $that)     {
-       
-                       // Load cache from BE User data
-               $cache = $GLOBALS['BE_USER']->getSessionData('be_acl');
-               if (!$cache)    $cache = array();
-               
+
+               $fileCachePath = PATH_site . 'typo3temp/beacl_cache/';
+               $filename = $fileCachePath . 'ppc_' . md5($that->user['uid'] . $params['perms']) . ',cache';
                        // Check if we can return something from cache
-               if (is_array($cache[$that->user['uid']])
-                       && $cache[$that->user['uid']][$params['perms']]) {
-                       return $cache[$that->user['uid']][$params['perms']];
-               }
+               if (file_exists($filename)) return file_get_contents($filename);     
+               
                
                        // get be_acl config in EM
                $beAclConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['be_acl']);
@@ -146,8 +142,7 @@ class tx_beacl_userAuthGroup {
                $str = ' ( '.$str.' ) ';
                
                        // Store data in cache
-               $cache[$that->user['uid']][$params['perms']] = $str;
-               $GLOBALS['BE_USER']->setAndSaveSessionData('be_acl', $cache);
+               file_put_contents($filename, $str);
                return $str;
        }
 
@@ -225,6 +220,25 @@ class tx_beacl_userAuthGroup {
                        $this->aclTraversePageTree($result['uid']);
                }
        }
+       
+       /**
+       * hook for clear cache, works for "all" and "configuration" clear command
+       * 
+       * @param array $params params for the hook
+       * @param object $pObj parent class (tcemain)
+       */
+       public function clearCache($params, $pObj) {
+               if($params['cacheCmd'] == 'temp_CACHED' || $params['cacheCmd'] == 'all') {
+                       $tempPath = PATH_site . 'typo3temp/beacl_cache/'; 
+                       $handle=opendir($tempPath);
+                       while ($data=readdir($handle)) {
+                               if (!is_dir($data) && $data != "." && $data != "..") {
+                                       unlink($tempPath . $data);
+                               }
+                       }
+                       closedir($handle);
+               }
+       }
 }
 
 ?>