Skip to content

Commit

Permalink
Do not change the session-stored subsite, if session is not enabled.
Browse files Browse the repository at this point in the history
This causes issues with Security::findAnAdmistrator which incorrectly
forces the current session-stored subsite to 0 - it uses
Subsite::currentSubsiteID before the session support is enabled, and
hence obtains wrong value.
  • Loading branch information
mateusz committed Nov 26, 2013
1 parent c04208e commit a771e22
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions code/model/Subsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,24 @@ public static function currentSubsiteID() {
* @param int|Subsite $subsite Either the ID of the subsite, or the subsite object itself
*/
public static function changeSubsite($subsite) {
// Session subsite change only meaningful if the session is active.
// Otherwise we risk setting it to wrong value, e.g. if we rely on currentSubsiteID.
if (!Subsite::$use_session_subsiteid) return;

if(is_object($subsite)) $subsiteID = $subsite->ID;
else $subsiteID = $subsite;

Session::set('SubsiteID', (int)$subsiteID);

// Set locale
if (is_object($subsite) && $subsite->Language != '') {
$locale = i18n::get_locale_from_lang($subsite->Language);
if($locale) {
i18n::set_locale($locale);
}
}
Permission::flush_permission_cache();

Permission::flush_permission_cache();
}

/**
Expand Down

0 comments on commit a771e22

Please sign in to comment.