From 9b381815b0404ea4ff339ca61a765db8a3665a1b Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Tue, 7 Mar 2023 14:22:05 -0500 Subject: [PATCH] Relationship Cache check --- CRM/Utils/Check/Component/Schema.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/CRM/Utils/Check/Component/Schema.php b/CRM/Utils/Check/Component/Schema.php index 8a4327f16c..56f121c611 100644 --- a/CRM/Utils/Check/Component/Schema.php +++ b/CRM/Utils/Check/Component/Schema.php @@ -249,7 +249,33 @@ class CRM_Utils_Check_Component_Schema extends CRM_Utils_Check_Component { ); $msg->addAction( ts('Rebuild triggers (also re-builds the phone number function)'), - ts('Create missing function now? This may take few minutes.'), + ts('Create missing function now? This may take a few minutes.'), + 'api3', + ['System', 'flush', ['triggers' => TRUE]] + ); + return [$msg]; + } + return []; + } + + /** + * Check the function to populate phone_numeric exists. + * + * @return array|\CRM_Utils_Check_Message[] + */ + public function checkRelationshipCacheTriggers():array { + $dao = CRM_Core_DAO::executeQuery("SHOW TRIGGERS WHERE (`Table` = 'civicrm_relationship' OR `Table` = 'civicrm_relationship_type') AND `Statement` LIKE '%civicrm_relationship_cache%';"); + if ($dao->N !== 3) { + $msg = new CRM_Utils_Check_Message( + __FUNCTION__, + ts("Your database is missing functionality to populate the relationship cache."), + ts('Missing Relationship Cache Trigger'), + \Psr\Log\LogLevel::WARNING, + 'fa-server' + ); + $msg->addAction( + ts('Rebuild triggers'), + ts('Create missing triggers now? This may take a few minutes.'), 'api3', ['System', 'flush', ['triggers' => TRUE]] ); -- 2.25.1