Fix deprecation warning on Price Set report
authoreileen <emcnaughton@wikimedia.org>
Mon, 25 Nov 2019 02:59:12 +0000 (15:59 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 25 Nov 2019 02:59:12 +0000 (15:59 +1300)
In 5.20 we added a deprecation warning on searches that are borked WRT filling the prev_next
cache & hence doing searches. The price set search falls into this camp & while it has
been broken forever the deprecation notice is new (& the fix is safe) so targettin 5.20

CRM/Contact/Selector.php

index faf4e64e2dcce687ac35d5b0d501431903260a02..7e7560a34f8bf9b27a3ab5d904cdf31188b7c322 100644 (file)
@@ -1016,6 +1016,8 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
    * @param string $cacheKey
    * @param int $start
    * @param int $end
+   *
+   * @throws \CRM_Core_Exception
    */
   public function fillupPrevNextCache($sort, $cacheKey, $start = 0, $end = self::CACHE_SIZE) {
     $coreSearch = TRUE;
@@ -1041,7 +1043,9 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
 
     $selectSQL = CRM_Core_DAO::composeQuery("SELECT DISTINCT %1, contact_a.id, contact_a.sort_name", [1 => [$cacheKey, 'String']]);
 
-    $sql = str_ireplace(["SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"], $selectSQL, $sql);
+    $sql = str_ireplace(['SELECT contact_a.id as contact_id', 'SELECT contact_a.id as id'], $selectSQL, $sql);
+    $sql = str_ireplace('ORDER BY `contact_id`', 'ORDER BY `id`', $sql, $sql);
+
     try {
       Civi::service('prevnext')->fillWithSql($cacheKey, $sql);
     }