Changeset 11854

Show
Ignore:
Timestamp:
08/30/07 12:04:31 (1 year ago)
Author:
bergie
Message:

Implement a cache backend that doesn't require PHP DBA extension and doesn't cause unnecessary I/O. refs #102

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.core/midcom/baseclasses/components/request.php

    r11845 r11854  
    647647                    debug_add("Handler method {$method} returned FALSE, we cannot handle this therefore."); 
    648648                    debug_pop(); 
     649                    return false; 
    649650                } 
    650651            } 
  • trunk/midcom/midcom.core/midcom/config/midcom_config.php

    r11853 r11854  
    342342// Cache configuration 
    343343$GLOBALS['midcom_config_default']['cache_base_directory'] = '/tmp/'; 
    344 $GLOBALS['midcom_config_default']['cache_autoload_queue'] = Array('content', /* 'nap', */ 'phpscripts', 'memcache'); 
     344$GLOBALS['midcom_config_default']['cache_autoload_queue'] = Array('content', /*'nap', */ 'phpscripts', 'memcache'); 
    345345 
    346346// Content Cache 
  • trunk/midcom/midcom.core/midcom/services/auth.php

    r11847 r11854  
    630630    function _prepare_authentication_drivers() 
    631631    { 
    632         debug_push_class(__CLASS__, __FUNCTION__); 
    633  
    634         debug_add('Loading Authentication Backend'); 
    635632        require_once (MIDCOM_ROOT . "/midcom/services/auth/backend/{$GLOBALS['midcom_config']['auth_backend']}.php"); 
    636633        $classname = "midcom_services_auth_backend_{$GLOBALS['midcom_config']['auth_backend']}"; 
    637634        $this->_auth_backend = new $classname(); 
    638635 
    639         debug_add('Loading Authentication Frontend'); 
    640636        require_once (MIDCOM_ROOT . "/midcom/services/auth/frontend/{$GLOBALS['midcom_config']['auth_frontend']}.php"); 
    641637        $classname = "midcom_services_auth_frontend_{$GLOBALS['midcom_config']['auth_frontend']}"; 
    642638        $this->_auth_frontend = new $classname(); 
    643  
    644         debug_pop(); 
    645639    } 
    646640 
     
    725719        }     
    726720        return $this->can_do_byguid($privilege, $content_object->guid, get_class($content_object), $user); 
    727         /* 
    728         debug_push_class(__CLASS__, __FUNCTION__); 
    729         if (   is_null($user) 
    730             && ! is_null($this->user) 
    731             && $this->admin) 
    732         { 
    733             // Administrators always have access. 
    734             debug_pop(); 
    735             return true; 
    736         } 
    737          
    738         debug_add("Querying privilege {$privilege} to " . get_class($content_object) . " {$content_object->guid}", MIDCOM_LOG_DEBUG); 
    739          
    740         if ($this->_internal_sudo) 
    741         { 
    742             debug_add('INTERNAL SUDO mode is enabled. Generic Read-Only mode set.', MIDCOM_LOG_DEBUG); 
    743             debug_pop(); 
    744             return $this->_can_do_internal_sudo($privilege); 
    745         } 
    746  
    747         if ($this->_component_sudo) 
    748         { 
    749             debug_pop(); 
    750             return true; 
    751         } 
    752  
    753         // Cache results of ACL checks per session 
    754         static $cached_privileges = array(); 
    755  
    756         if (is_null($this->user)) 
    757         { 
    758             $privilege_key = "{$content_object->guid}-{$privilege}"; 
    759         } 
    760         else 
    761         { 
    762             $privilege_key = "{$this->user->id}-{$content_object->guid}-{$privilege}"; 
    763         } 
    764          
    765         if (!array_key_exists($privilege_key, $cached_privileges)) 
    766         { 
    767             $full_privileges = $this->get_privileges($content_object, $user); 
    768      
    769             if (! array_key_exists($privilege, $full_privileges)) 
    770             { 
    771                 debug_add("The privilege {$privilege} is unknown at this point. Assuming not granted privilege.", MIDCOM_LOG_WARN); 
    772                 debug_pop(); 
    773                 return false; 
    774             } 
    775      
    776             if ($full_privileges[$privilege] == MIDCOM_PRIVILEGE_ALLOW) 
    777             { 
    778                 $cached_privileges[$privilege_key] = true; 
    779             } 
    780             else 
    781             { 
    782                 $cached_privileges[$privilege_key] = false; 
    783             } 
    784         } 
    785         debug_pop(); 
    786         return $cached_privileges[$privilege_key]; 
    787         */ 
    788721    } 
    789722 
     
    1028961    { 
    1029962        return $this->get_privileges_byguid($privilege, $content_object->guid, get_class($content_object), $user); 
    1030         /* 
    1031         if (is_null($user)) 
    1032         { 
    1033             $user =& $this->user; 
    1034         } 
    1035  
    1036         if (is_string($user)) 
    1037         { 
    1038             if ($user == 'EVERYONE') 
    1039             { 
    1040                 $user = null; 
    1041             } 
    1042             else 
    1043             { 
    1044                 $user =& $_MIDCOM->auth->get_user($user); 
    1045             } 
    1046         } 
    1047  
    1048  
    1049         if (! $_MIDCOM->dbclassloader->is_midcom_db_object($content_object)) 
    1050         { 
    1051             $object = $_MIDCOM->dbfactory->convert_midgard_to_midcom($content_object); 
    1052             if (is_null($object)) 
    1053             { 
    1054                 debug_push_class(__CLASS__, __FUNCTION__); 
    1055                 debug_add('Failed to convert an object, falling back to an empty privilege set for the object in question. See debug level log for details.'); 
    1056                 debug_print_r('Content object was:', $content_object); 
    1057                 debug_pop(); 
    1058                 return Array(); 
    1059             } 
    1060         } 
    1061         else 
    1062         { 
    1063             $object =& $content_object; 
    1064         } 
    1065  
    1066         // Check for a cache Hit. 
    1067         $cache_user_id = is_null($user) ? 'EVERYONE' : $user->id; 
    1068         $cache_id = "{$cache_user_id}:{$object->guid}"; 
    1069         if (array_key_exists($cache_id, $this->_privileges_cache)) 
    1070         { 
    1071             $full_privileges = $this->_privileges_cache[$cache_id]; 
    1072         } 
    1073         else 
    1074         { 
    1075             if (   is_null($user) 
    1076                 || (    !is_object($user) 
    1077                     && $user == 'EVERYONE')) 
    1078             { 
    1079                 $user_privileges = Array(); 
    1080                 $user_per_class_privileges = Array(); 
    1081             } 
    1082             else 
    1083             { 
    1084                 $user_privileges = $user->get_privileges(); 
    1085                 $user_per_class_privileges = $user->get_per_class_privileges($object); 
    1086             } 
    1087             $this->_load_class_magic_privileges($object); 
    1088  
    1089             // Remember to sync this merging chain with can_user_do. 
    1090             $full_privileges = array_merge 
    1091             ( 
    1092                 $this->_default_privileges, 
    1093                 $this->_default_magic_class_privileges[$object->__new_class_name__]['EVERYONE'], 
    1094                 ( 
    1095                     (is_null($this->user)) 
    1096                         ? $this->_default_magic_class_privileges[$object->__new_class_name__]['ANONYMOUS'] 
    1097                         : $this->_default_magic_class_privileges[$object->__new_class_name__]['USERS'] 
    1098                 ), 
    1099                 $user_privileges, 
    1100                 $user_per_class_privileges, 
    1101                 midcom_core_privilege::collect_content_privileges($object) 
    1102             ); 
    1103  
    1104             $this->_privileges_cache[$cache_id] = $full_privileges; 
    1105         } 
    1106  
    1107         return $full_privileges; 
    1108         */ 
    1109963    } 
    1110964 
  • trunk/midcom/midcom.core/midcom/services/cache/module/content.php

    r11846 r11854  
    230230        if (! array_key_exists('driver', $backend_config)) 
    231231        { 
    232             $backend_config['driver'] = 'dba'; 
     232            $backend_config['driver'] = 'null'; 
    233233        } 
    234234