Skip to content

Commit

Permalink
Merge pull request #834 from tractorcow-farm/fix/dbready-check-7
Browse files Browse the repository at this point in the history
fix: check for request prior to access
  • Loading branch information
tractorcow authored Mar 24, 2024
2 parents 6961bc7 + 11e92f4 commit 68c6b47
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 68c6b47

Please sign in to comment.