From 42e799bc43eb83660bc4d35c9c6c5bf7f23989a8 Mon Sep 17 00:00:00 2001 From: Florian Thoma Date: Sat, 9 Jun 2018 20:37:52 +0200 Subject: [PATCH 1/2] fix Versioned::choose_site_stage() if no request given Load request from curent controller as a fallback --- model/Versioned.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/Versioned.php b/model/Versioned.php index ff0209389..d25b0365e 100644 --- a/model/Versioned.php +++ b/model/Versioned.php @@ -1216,7 +1216,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider { */ public static function choose_site_stage(SS_HTTPRequest $request = null) { if (!$request) { - throw new InvalidArgumentException("Request not found"); + $request = Controller::curr()->getRequest(); } $mode = static::get_default_reading_mode(); From c9005b2a70c3084a5755ca804c0f208b91c8d5c3 Mon Sep 17 00:00:00 2001 From: Florian Thoma Date: Mon, 11 Jun 2018 08:07:37 +0200 Subject: [PATCH 2/2] add check for currentl controller --- model/Versioned.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/model/Versioned.php b/model/Versioned.php index d25b0365e..d5a54d7ee 100644 --- a/model/Versioned.php +++ b/model/Versioned.php @@ -1215,9 +1215,13 @@ class Versioned extends DataExtension implements TemplateGlobalProvider { * @param SS_HTTPRequest|null $request */ public static function choose_site_stage(SS_HTTPRequest $request = null) { - if (!$request) { + if (!$request && Controller::has_curr()) { $request = Controller::curr()->getRequest(); } + if (!$request) { + throw new InvalidArgumentException("Request not found"); + } + $mode = static::get_default_reading_mode(); // Check any pre-existing session mode