CRM-15231 - Fatal error on search when ACLs are enabled
authoratif-shaikh <shaikh388@gmail.com>
Tue, 9 Sep 2014 13:15:12 +0000 (18:45 +0530)
committeratif-shaikh <shaikh388@gmail.com>
Tue, 9 Sep 2014 13:15:12 +0000 (18:45 +0530)
https://issues.civicrm.org/jira/browse/CRM-15231

CRM/Contact/BAO/Query.php

index 84ed1af12c6bf54bfd162d5a9a3cee7b7b78642a..c4431c9ec11ed0eb4cb474ca2421748b160ddab7 100644 (file)
@@ -4597,6 +4597,7 @@ civicrm_relationship.is_permission_a_b = 0
     }
 
     // note : this modifies _fromClause and _simpleFromClause
+    $this->_sort = $sort;
     $this->includePseudoFieldsJoin($sort);
 
     list($select, $from, $where, $having) = $this->query($count, $sortByChar, $groupContacts, $onlyDeleted);
@@ -4694,13 +4695,11 @@ civicrm_relationship.is_permission_a_b = 0
         if (!$count) {
           $this->_useDistinct = TRUE;
         }
-
-        if (empty($this->_fromClause)) {
-          $this->_fromClause = self::fromClause($this->_tables, NULL, NULL, $this->_primaryLocation, $this->_mode);
-        }
-
-        if (empty($this->_simpleFromClause)) {
-          $this->_simpleFromClause = self::fromClause($this->_whereTables, NULL, NULL, $this->_primaryLocation, $this->_mode);
+        //CRM-15231
+        $this->_fromClause = self::fromClause($this->_tables, NULL, NULL, $this->_primaryLocation, $this->_mode);
+        $this->_simpleFromClause = self::fromClause($this->_whereTables, NULL, NULL, $this->_primaryLocation, $this->_mode);
+        if (!empty($_GET['crmSID'])) {
+          $this->includePseudoFieldsJoin($this->_sort);
         }
       }
     }