Skip to content

Commit

Permalink
Merge pull request #17817 from colemanw/getChecksConfig
Browse files Browse the repository at this point in the history
Simplify caching of status checks
  • Loading branch information
eileenmcnaughton authored Jul 27, 2020
2 parents 27cd872 + 1416a3c commit 6010fe3
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions CRM/Utils/Check/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
*/
abstract class CRM_Utils_Check_Component {

/**
* @var array
*/
public $checksConfig = [];

/**
* Get the configured status checks.
*
Expand All @@ -32,20 +27,12 @@ abstract class CRM_Utils_Check_Component {
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function getChecksConfig() {
if (empty($this->checksConfig)) {
$this->checksConfig = Civi::cache('checks')->get('checksConfig', []);
if (empty($this->checksConfig)) {
$this->checksConfig = StatusPreference::get(FALSE)->execute()->indexBy('name');
}
if (empty(Civi::$statics[__FUNCTION__])) {
Civi::$statics[__FUNCTION__] = (array) StatusPreference::get(FALSE)
->addWhere('domain_id', '=', 'current_domain')
->execute()->indexBy('name');
}
return $this->checksConfig;
}

/**
* @param array $checksConfig
*/
public function setChecksConfig(array $checksConfig) {
$this->checksConfig = $checksConfig;
return Civi::$statics[__FUNCTION__];
}

/**
Expand Down

0 comments on commit 6010fe3

Please sign in to comment.