Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.4.4, 4.4.5
-
Fix Version/s: 4.5
-
Component/s: None
-
Labels:None
Description
The following query causes the problem:
"SELECT DISTINCT lt.id FROM `civicrm`.`log_civicrm_note` lt
WHERE lt.log_conn_id = 219
AND lt.log_date BETWEEN DATE_SUB('20140424093302', INTERVAL 10 SECOND)
AND DATE_ADD('20140424093302', INTERVAL 10 SECOND)
AND ( entity_id = 202 AND entity_table = 'civicrm_contact' )
OR (entity_id IN (SELECT note.id FROM `civicrm`.log_civicrm_note note
WHERE note.entity_id = 202 AND note.entity_table = 'civicrm_contact')
AND entity_table = 'civicrm_note');"
More precisely, the last part of the query:
"AND ( entity_id = 202 AND entity_table = 'civicrm_contact' )
OR (entity_id IN (SELECT note.id FROM `civicrm`.log_civicrm_note note
WHERE note.entity_id = 202 AND note.entity_table = 'civicrm_contact')
AND entity_table = 'civicrm_note');"
(built by CRM/Logging/Differ.php:79 as $contactIdClause) should
obviously filter the notes associated to a specific contact.
But the lack of parenthesis around the OR-operator changes the hierarchy
of the entire WHERE clause.
I think this should be one AND-clause with an encapsulated OR-clause:
"AND (( entity_id = 202 AND entity_table = 'civicrm_contact' ) OR
(entity_id IN (SELECT note.id FROM `civicrm`.log_civicrm_note note WHERE
note.entity_id = 202 AND note.entity_table = 'civicrm_contact') AND
entity_table = 'civicrm_note'));"