mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Do not change the session-stored subsite, if session is not enabled.
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.
This commit is contained in:
parent
c04208ed79
commit
a771e2239b
@ -123,11 +123,15 @@ class Subsite extends DataObject implements PermissionProvider {
|
|||||||
* @param int|Subsite $subsite Either the ID of the subsite, or the subsite object itself
|
* @param int|Subsite $subsite Either the ID of the subsite, or the subsite object itself
|
||||||
*/
|
*/
|
||||||
public static function changeSubsite($subsite) {
|
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;
|
if(is_object($subsite)) $subsiteID = $subsite->ID;
|
||||||
else $subsiteID = $subsite;
|
else $subsiteID = $subsite;
|
||||||
|
|
||||||
Session::set('SubsiteID', (int)$subsiteID);
|
Session::set('SubsiteID', (int)$subsiteID);
|
||||||
|
|
||||||
// Set locale
|
// Set locale
|
||||||
if (is_object($subsite) && $subsite->Language != '') {
|
if (is_object($subsite) && $subsite->Language != '') {
|
||||||
$locale = i18n::get_locale_from_lang($subsite->Language);
|
$locale = i18n::get_locale_from_lang($subsite->Language);
|
||||||
@ -135,8 +139,8 @@ class Subsite extends DataObject implements PermissionProvider {
|
|||||||
i18n::set_locale($locale);
|
i18n::set_locale($locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Permission::flush_permission_cache();
|
Permission::flush_permission_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user