Skip to content

Commit

Permalink
fix: check for request prior to access
Browse files Browse the repository at this point in the history
  • Loading branch information
tractorcow committed Mar 24, 2024
1 parent 6961bc7 commit 11e92f4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Model/CachableModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 11e92f4

Please sign in to comment.