Changeset 11931

Show
Ignore:
Timestamp:
08/31/07 00:14:50 (1 year ago)
Author:
bergie
Message:

Fix auth caching, remove excessive output, refs #102

Files:

Legend:

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

    r11916 r11931  
    112112require('midcom/baseclasses/components/purecode.php'); 
    113113require('midcom/baseclasses/components/request.php'); 
    114 //require('midcom/baseclasses/components/request_admin.php'); 
    115114 
    116115// Note, that the legacy MidCOM base classes are loaded at the end of this file, 
  • trunk/midcom/midcom.core/midcom/helper/_componentloader.php

    r11900 r11931  
    691691    function load_all_manifests() 
    692692    { 
    693         debug_push_class(__CLASS__, __FUNCTION__); 
    694  
    695693        $cache_identifier = $_MIDCOM->cache->phpscripts->create_identifier('midcom.componentloader', 'manifests'); 
    696694 
     
    706704        if (! $cache_hit) 
    707705        { 
    708             debug_add('We generate the class manifest cache now.'); 
     706            debug_push_class(__CLASS__, __FUNCTION__); 
     707            debug_add('Cache miss, generating component manifest cache now.'); 
    709708            $this->_generate_class_manifest_cache($cache_identifier); 
    710         } 
    711         else 
    712         { 
    713             debug_add('We could load the manifests from the cache, so we are fine now.'); 
    714         } 
    715  
    716         debug_pop(); 
     709            debug_pop(); 
     710        } 
    717711    } 
    718712 
  • trunk/midcom/midcom.core/midcom/services/auth.php

    r11903 r11931  
    585585        if (! $this->_auth_backend->read_login_session()) 
    586586        { 
    587             debug_push_class(__CLASS__, __FUNCTION__); 
    588             debug_add('The backend did not detect a running session, continuing in the previous authentication state.'); 
    589             debug_pop(); 
    590587            return; 
    591588        } 
     
    768765        if (is_null($for_user)) 
    769766        { 
    770             $privilege_key = "{$object_guid}-{$privilege}"; 
     767                $cache_key = "{$object_guid}"; 
     768                $privilege_key = "{$cache_key}-{$privilege}"; 
    771769        } 
    772770        else 
     
    774772            if (is_string($for_user)) 
    775773            { 
    776                 $privilege_key = "{$for_user}-{$object_guid}-{$privilege}"; 
     774                $cache_key = "{$for_user}-{$object_guid}"; 
     775                $privilege_key = "{$cache_key}-{$privilege}"; 
    777776            } 
    778777            else 
    779778            { 
    780                 $privilege_key = "{$for_user->id}-{$object_guid}-{$privilege}"; 
    781             } 
    782         } 
    783  
    784         if (!array_key_exists($privilege_key, $cached_privileges)) 
     779                $cache_key = "{$for_user->id}-{$object_guid}"; 
     780                $privilege_key = "{$cache_key}-{$privilege}"; 
     781            } 
     782        } 
     783 
     784        if (!isset($cached_privileges[$privilege_key])) 
    785785        { 
    786786            debug_push_class(__CLASS__, __FUNCTION__);         
    787             debug_add("Cache miss, fetching privileges for {$object_guid}"); 
     787            debug_add("Cache {$privilege_key} miss, fetching privileges for {$object_guid}"); 
    788788            debug_pop(); 
    789789            $full_privileges = $this->get_privileges_byguid($object_guid, $object_class, $user); 
    790      
     790            foreach ($full_privileges as $priv => $value) 
     791            { 
     792                if ($value == MIDCOM_PRIVILEGE_ALLOW) 
     793                { 
     794                    $cached_privileges["{$cache_key}-{$priv}"] = true; 
     795                } 
     796                else 
     797                { 
     798                    $cached_privileges["{$cache_key}-{$priv}"] = false; 
     799                } 
     800            } 
     801             
    791802            if (! array_key_exists($privilege, $full_privileges)) 
    792803            { 
     
    796807                return false; 
    797808            } 
    798      
    799             if ($full_privileges[$privilege] == MIDCOM_PRIVILEGE_ALLOW) 
    800             { 
    801                 $cached_privileges[$privilege_key] = true; 
    802             } 
    803             else 
    804             { 
    805                 $cached_privileges[$privilege_key] = false; 
    806             } 
    807         } 
    808         debug_pop(); 
     809        } 
     810 
    809811        return $cached_privileges[$privilege_key]; 
    810812    } 
     
    993995            if (empty($user)) 
    994996            { 
    995                 $cache_user_id = null
     997                $cache_user_id = 'anonymous'
    996998            } 
    997999            else 
     
    10411043                debug_push_class(__CLASS__, __FUNCTION__); 
    10421044                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.'); 
    1043                 debug_print_r('Content object was:', $dummy_object_init); 
    10441045                debug_pop(); 
    10451046                return Array(); 
     
    10601061        { 
    10611062            debug_push_class(__CLASS__, __FUNCTION__); 
    1062             debug_add("cache miss for {$cache_id}"); 
    1063             debug_pop(); 
     1063            debug_add("Cache miss for {$cache_id}"); 
     1064            debug_pop();         
    10641065            if (   is_object($user) 
    10651066                && method_exists($user, 'get_privileges')