Merge pull request #8154 from xini/patch-4

fix Versioned::choose_site_stage() if no request given
This commit is contained in:
Damian Mooyman 2018-06-13 13:45:00 +12:00 committed by GitHub
commit 1acb80851c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1215,9 +1215,13 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
* @param SS_HTTPRequest|null $request * @param SS_HTTPRequest|null $request
*/ */
public static function choose_site_stage(SS_HTTPRequest $request = null) { public static function choose_site_stage(SS_HTTPRequest $request = null) {
if (!$request && Controller::has_curr()) {
$request = Controller::curr()->getRequest();
}
if (!$request) { if (!$request) {
throw new InvalidArgumentException("Request not found"); throw new InvalidArgumentException("Request not found");
} }
$mode = static::get_default_reading_mode(); $mode = static::get_default_reading_mode();
// Check any pre-existing session mode // Check any pre-existing session mode