Merge pull request #10020 from jitendrapurohit/CRM-20216
[civicrm-core.git] / CRM / Core / Reference / Basic.php
index 411d30627bdf011a5c75b6d531b55a57462559a6..797d5832ab9de9784ecce172c8673f0d4866d8d7 100644 (file)
@@ -78,11 +78,16 @@ class CRM_Core_Reference_Basic implements CRM_Core_Reference_Interface {
    */
   public function findReferences($targetDao) {
     $targetColumn = $this->getTargetKey();
+    $select = 'id';
+    // CRM-19385: Since id is removed, return all rows for cache tables.
+    if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists($this->getReferenceTable(), 'id')) {
+      $select = '*';
+    }
     $params = array(
       1 => array($targetDao->$targetColumn, 'String'),
     );
     $sql = <<<EOS
-SELECT id
+SELECT {$select}
 FROM {$this->getReferenceTable()}
 WHERE {$this->getReferenceKey()} = %1
 EOS;
@@ -103,7 +108,7 @@ EOS;
       1 => array($targetDao->$targetColumn, 'String'),
     );
     $sql = <<<EOS
-SELECT count(id)
+SELECT count(*)
 FROM {$this->getReferenceTable()}
 WHERE {$this->getReferenceKey()} = %1
 EOS;