From fb1c6b2c7ccab376f3dcd71766f8c8ffb557e3df Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 10 Oct 2016 10:19:29 +1100 Subject: [PATCH] Further test fixes --- CRM/Core/BAO/Note.php | 2 +- CRM/Core/DAO.php | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CRM/Core/BAO/Note.php b/CRM/Core/BAO/Note.php index c33642acd2..a5646795eb 100644 --- a/CRM/Core/BAO/Note.php +++ b/CRM/Core/BAO/Note.php @@ -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'); } diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 4d7829d778..1d75421305 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -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) { -- 2.25.1