Skip to content

Commit

Permalink
Merge pull request #833 from tractorcow-farm/fix/dbready-check-6
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 4c1f1e8 + 8985d8c commit 9e650e6
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 9e650e6

Please sign in to comment.