From c9005b2a70c3084a5755ca804c0f208b91c8d5c3 Mon Sep 17 00:00:00 2001 From: Florian Thoma Date: Mon, 11 Jun 2018 08:07:37 +0200 Subject: [PATCH] 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