From 8985d8c8db9f69ae7d1c9e44bb3e1b122c94f074 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 25 Mar 2024 11:08:46 +1300 Subject: [PATCH] fix: check for request prior to access --- src/Model/CachableModel.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Model/CachableModel.php b/src/Model/CachableModel.php index c005deec..394c1637 100644 --- a/src/Model/CachableModel.php +++ b/src/Model/CachableModel.php @@ -71,10 +71,12 @@ public static function clearCached() protected static function databaseIsReady() { // Outside of dev/ don't actually do any checks, assume ready - /** @var HTTPRequest $request */ - $request = Injector::inst()->get(HTTPRequest::class); - if (stripos($request->getURL(false), 'dev/') !== 0) { - return true; + if (Injector::inst()->has(HTTPRequest::class)) { + /** @var HTTPRequest $request */ + $request = Injector::inst()->get(HTTPRequest::class); + if (stripos($request->getURL(false), 'dev/') !== 0) { + return true; + } } $object = DataObject::singleton(static::class);