From 6961bc7b0bd54ab1fa5d60f7e3586fbbb0184f21 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 25 Mar 2024 10:58:17 +1300 Subject: [PATCH] fix: don't invoke db for ready check outside of dev urls fixes #828 --- src/Model/CachableModel.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Model/CachableModel.php b/src/Model/CachableModel.php index c90c61f1..d7baeb8d 100644 --- a/src/Model/CachableModel.php +++ b/src/Model/CachableModel.php @@ -2,6 +2,8 @@ namespace TractorCow\Fluent\Model; +use SilverStripe\Control\Director; +use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Injector\Injector; @@ -68,6 +70,13 @@ 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; + } + $object = DataObject::singleton(static::class); // if any of the tables aren't created in the database