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) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Found a bug in Export and fixed it. Next Step?
Pages: [1]

Author Topic: Found a bug in Export and fixed it. Next Step?  (Read 927 times)

fehlicks

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 3.4.2
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5
Found a bug in Export and fixed it. Next Step?
May 30, 2012, 05:05:49 am
Hi,

I am new to the Forum and have a question:

I found a bug in the CiviCRM-Export and know how to fix it. What are the next steps?
I searched in the IssueTracker and did not find a reported bug.
Should I create a new Issue?


Here is the bug and the fix:

When exporting a contact with a relationship and using an export-sheme, for Instance: the postal-code of an employer.

You choose which fields to export:

THIS WORKS:
 primary address: postal code
 private address: postal code
 billing address: postal code
 related employer: primary address: postal code
 related employer: private address: postal code
 related employer: billing address: postal code

The Result is a XLS with 6 Fields

DOES NOT WORK:
 related employer: primary address: postal code
 related employer: private address: postal code
 related employer: billing address: postal code
 primary address: postal code
 private address: postal code
 billing address: postal code

The Result is a XLS with only 4 Rows.

REASON:
CRM/Export/BAO/Export.php has a bug.
The variable $relationField is not cleared in the foreach-loop and therefore still contains a value from the last iteration. This bug is encouraged by the fact, that this variable is set with a scope for the whole function, instead of only the loop.

FIX:
limit the scope:
change line 87
 $queryMode  = $relationField = null;
to
 $queryMode  = null;

clear the variable at start of the loop:
after line 145
  $phoneTypeId = $imProviderId = null;
insert:
 $relationField = null;

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Found a bug in Export and fixed it. Next Step?
May 30, 2012, 05:52:55 am

great, thanx for doing the analysis and figuring out the issue. Much appreciated :)

here are the next steps:

1. Please file an issue here: http://issues.civicrm.org/

2. Please create a unified diff of your changes and attach it to the issue

http://en.wikipedia.org/wiki/Diff#Unified_format

3. For extra credit, can you please write a unit test to ensure that the export code works in the below case

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Found a bug in Export and fixed it. Next Step?

This forum was archived on 2017-11-26.