From 4e9bd6c75d201a9318f49f88122941a60d509ece Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 12 Dec 2022 21:35:52 -0800 Subject: [PATCH] getSiteStats - Use consistent report format When general usage stats are enabled, the format should be consistent across versions. Before (4.7 - 5.56): Report stat as 'Delivered' Before (5.57.beta1): Report stat as 'MailingEventDelivered' After (5.57.beta1): Report stat as 'Delivered' --- CRM/Utils/VersionCheck.php | 4 +++- tests/phpunit/CRM/Utils/versionCheckTest.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CRM/Utils/VersionCheck.php b/CRM/Utils/VersionCheck.php index 6b0376cf71..56da0c7564 100644 --- a/CRM/Utils/VersionCheck.php +++ b/CRM/Utils/VersionCheck.php @@ -203,6 +203,8 @@ class CRM_Utils_VersionCheck { 'CRM_Pledge_DAO_PledgeBlock' => NULL, 'CRM_Mailing_Event_DAO_MailingEventDelivered' => NULL, ]; + // Provide continuity in wire format. + $compat = ['MailingEventDelivered' => 'Delivered']; foreach ($tables as $daoName => $where) { if (class_exists($daoName)) { /** @var \CRM_Core_DAO $dao */ @@ -212,7 +214,7 @@ class CRM_Utils_VersionCheck { } $short_name = substr($daoName, strrpos($daoName, '_') + 1); $this->stats['entities'][] = [ - 'name' => $short_name, + 'name' => $compat[$short_name] ?? $short_name, 'size' => $dao->count(), ]; } diff --git a/tests/phpunit/CRM/Utils/versionCheckTest.php b/tests/phpunit/CRM/Utils/versionCheckTest.php index 1d152a3337..dba85f9cc4 100644 --- a/tests/phpunit/CRM/Utils/versionCheckTest.php +++ b/tests/phpunit/CRM/Utils/versionCheckTest.php @@ -216,7 +216,8 @@ class CRM_Utils_versionCheckTest extends CiviUnitTestCase { 'MembershipBlock', 'Pledge', 'PledgeBlock', - 'MailingEventDelivered', + 'Delivered', + // TIP: If an entity is renamed, then update VersionCheck's $compat list. ]; sort($entity_names); sort($expected_entity_names); -- 2.25.1