ENHANCEMENT: Be more specific about when the permission cache is flushed, so that the CMS can be more efficient. (from r83435)

This commit is contained in:
Tom Rix 2010-03-01 02:56:58 +00:00
parent 53d51e40ba
commit 6d1b3901df

View File

@ -219,7 +219,7 @@ JS;
$id = Session::get('SubsiteID'); $id = Session::get('SubsiteID');
} }
if(!isset($id) || $id === NULL) { if($id === NULL) {
$id = self::getSubsiteIDForDomain(); $id = self::getSubsiteIDForDomain();
Session::set('SubsiteID', $id); Session::set('SubsiteID', $id);
} }
@ -248,10 +248,12 @@ JS;
if(is_object($subsite)) $subsiteID = $subsite->ID; if(is_object($subsite)) $subsiteID = $subsite->ID;
else $subsiteID = $subsite; else $subsiteID = $subsite;
Session::set('SubsiteID', $subsiteID); Session::set('SubsiteID', (int)$subsiteID);
// And clear caches // Only bother flushing caches if we've actually changed
Permission::flush_permission_cache() ; if($subsiteID != self::currentSubsiteID()) {
Permission::flush_permission_cache();
}
} }
/** /**
@ -291,6 +293,9 @@ JS;
if(sizeof($subsiteIDs) > 1) user_error("Multiple subsites match '$host'", E_USER_WARNING); if(sizeof($subsiteIDs) > 1) user_error("Multiple subsites match '$host'", E_USER_WARNING);
return $subsiteIDs[0]; return $subsiteIDs[0];
} }
// Default subsite id = 0, the main site
return 0;
} }
function getMembersByPermission($permissionCodes = array('ADMIN')){ function getMembersByPermission($permissionCodes = array('ADMIN')){