ContactType - Ensure stable order
authorcolemanw <coleman@civicrm.org>
Tue, 12 Dec 2023 16:28:59 +0000 (11:28 -0500)
committercolemanw <coleman@civicrm.org>
Tue, 12 Dec 2023 16:28:59 +0000 (11:28 -0500)
MySql *usually* returns records ordered by id, but not always.
This keeps it stable.

CRM/Contact/BAO/ContactType.php

index 0059f499e4afed03ff37d62a1666271290dc0342..30c064e88842be7c31a68326c6d9f96bd05086e5 100644 (file)
@@ -837,6 +837,8 @@ WHERE ($subtypeClause)";
     $contactTypes = $cache->get($cacheKey);
     if ($contactTypes === NULL) {
       $query = CRM_Utils_SQL_Select::from('civicrm_contact_type');
+      // Ensure stable order
+      $query->orderBy('id');
       $dao = CRM_Core_DAO::executeQuery($query->toSQL());
       $contactTypes = array_column($dao->fetchAll(), NULL, 'name');
       $parents = array_column($contactTypes, NULL, 'id');