Further test fixes
authorSeamus Lee <seamuslee001@gmail.com>
Sun, 9 Oct 2016 23:19:29 +0000 (10:19 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Sun, 9 Oct 2016 23:19:29 +0000 (10:19 +1100)
CRM/Core/BAO/Note.php
CRM/Core/DAO.php

index c33642acd25536dab7296521783970ef5f0c455a..a5646795eb8eb651696fb20162263e8cacb20f43 100644 (file)
@@ -143,7 +143,7 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
       return CRM_Core_DAO::$_nullObject;
     }
 
-    if ($params['entity_table'] == 'civicrm_contact' && !empty($params['check_permissions'])) {
+    if (!empty($params['entity_table']) && $params['entity_table'] == 'civicrm_contact' && !empty($params['check_permissions'])) {
       if (!CRM_Contact_BAO_Contact_Permission::allow($params['entity_id'], CRM_Core_Permission::EDIT)) {
         throw new CRM_Exception('Permission denied to modify contact record');
       }
index 4d7829d778e2506c4b66840147d4d433cd34b360..1d754213052128a3abaa898de27f33a91d55de68 100644 (file)
@@ -2436,13 +2436,15 @@ SELECT contact_id
         $relatedClauses = array();
         $relatedEntities = $this->buildOptions('entity_table', 'get');
         foreach ((array) $relatedEntities as $table => $ent) {
-          $ent = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($table));
-          $subquery = CRM_Utils_SQL::mergeSubquery($ent);
-          if ($subquery) {
-            $relatedClauses[] = "(entity_table = '$table' AND entity_id " . implode(' AND entity_id ', $subquery) . ")";
-          }
-          else {
-            $relatedClauses[] = "(entity_table = '$table')";
+          if (!empty($ent)) {
+            $ent = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($table));
+            $subquery = CRM_Utils_SQL::mergeSubquery($ent);
+            if ($subquery) {
+              $relatedClauses[] = "(entity_table = '$table' AND entity_id " . implode(' AND entity_id ', $subquery) . ")";
+            }
+            else {
+              $relatedClauses[] = "(entity_table = '$table')";
+            }
           }
         }
         if ($relatedClauses) {