CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Bug with Logging Details - Replicated on Demo
Pages: [1]

Author Topic: Bug with Logging Details - Replicated on Demo  (Read 14277 times)

AlexR

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • CiviCRM version: 4.3.1
  • CMS version: Drupal
  • MySQL version: 5.1.69
  • PHP version: 5.3.23
Bug with Logging Details - Replicated on Demo
July 30, 2013, 10:25:56 am
When multiple contacts are updated at the same time, the logging detail for a single event shows data for multiple events. I was able to replicate this issue on the demo site.

I made an update to two contacts and the following two rows appeared in the Contact Logging Report (Summary) http://i.imgur.com/w4h7AX8.png

The Contact Logging Report (Details) for each of the events are http://i.imgur.com/xXboiKx.png and http://i.imgur.com/HGi55mf.png
You can see on the second link that is shows the details for both events.

The SQL that selects the contact ids for the report is:

Code: [Select]
SELECT DISTINCT lt.id FROM `log_table` lt
 
WHERE log_conn_id = %1 AND
      log_date BETWEEN DATE_SUB(%2, INTERVAL 10 SECOND) AND DATE_ADD(%2, INTERVAL 10 SECOND)

The query is only based on connection id and log date. Since multiple updates at the same time with have the same connection id and will occur within +/- 10 seconds, multiple contact ids are selected.

An additional where clause can be generated if the contact id is passed but the following code never seems to pull a value:

Code: [Select]
$this->cid         = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);

AlexR

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • CiviCRM version: 4.3.1
  • CMS version: Drupal
  • MySQL version: 5.1.69
  • PHP version: 5.3.23
Re: Bug with Logging Details - Replicated on Demo
July 30, 2013, 10:55:22 am
I guess I solved my own problem.

in CRM/Report/Form/Contact/LoggingSummary.php I added a line to the alterDisplay(&$rows) function

Code: [Select]
$this->cid = $row['log_civicrm_entity_altered_contact_id'];
This adds the contact id to the logging detail url, which sets $this->cid such that the where clause in appended.

in CRM/Logging/ReportDetail I added to the $params array in the buildQuickForm function a 3rd element such that:

Code: [Select]
    $params = array(
      1 => array($this->log_conn_id, 'Integer'),
      2 => array($this->log_date, 'String'),
      3 => array($this->cid, 'Integer'),
    );

And finally, in CRM/Report/Form/Contact/LoggingDetail.php I added to the whoWhomWhenSql functions where clause such that:

Code: [Select]
WHERE l.log_action == 'Update' AND l.log_conn_id = %1 AND l.log_date = %2 AND l.id = %3 LIMIT 1
This ensures that the correct name is displayed on the detail report.

AlexR

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • CiviCRM version: 4.3.1
  • CMS version: Drupal
  • MySQL version: 5.1.69
  • PHP version: 5.3.23
Re: Bug with Logging Details - Replicated on Demo
July 31, 2013, 09:43:01 am
I had to alter $params because it was causing an issue with the Contribution Logging Report (Detail)

Code: [Select]
    $params = array(
      1 => array($this->log_conn_id, 'Integer'),
      2 => array($this->log_date, 'String'),
    );
   
    if(CRM_Utils_Array::value('title', $this->_params) !== 'Contribution Logging Report (Detail)'){
    $params[3] = array($this->cid, 'Integer');
    } else {
    $this->log_date = str_replace( array('-', ':', ' ') , '', $this->log_date);
    }

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Bug with Logging Details - Replicated on Demo

This forum was archived on 2017-11-26.