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) »
  • Importing contacts Error line 1048
Pages: [1]

Author Topic: Importing contacts Error line 1048  (Read 875 times)

J Slomp

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Drupal
  • MySQL version: 5.*
  • PHP version: 5.3
Importing contacts Error line 1048
April 03, 2013, 10:22:01 am
Hi,

Just noticed a bug, and couldn't find a bug report.



Fatal error: Cannot use string offset as an array in /home/*****/public_html/sites/all/modules/civicrm/CRM/Import/Parser/Contact.php on line 1048

Change:
if (civicrm_error($newContact)) {
          $contactID = $newContact['error_message']['params'][0];
     if (!in_array($contactID, $this->_newContacts)) {
            $this->_newContacts[] = $contactID;
          }
        }


to:
        if (civicrm_error($newContact) && is_array($newContact)) {
         if(is_array($newContact['error_message'])){
            $contactID = $newContact['error_message']['params'][0];
         } else {
            $this->_newContacts[] = $newContact['error_message'];
         }
        if (!in_array($contactID, $this->_newContacts)) {
            $this->_newContacts[] = $contactID;
          }
        }


Not sure if this is the way to fix it, but now I did not get an error.

The import data was "Yes" or "No", the CSV contained Yes, what should have been 1


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: Importing contacts Error line 1048
April 03, 2013, 10:40:46 am

can you please try and reproduce this error on our demo server. Also can you attach the csv file and mapping (if not too complex) you used to get this error

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

J Slomp

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Drupal
  • MySQL version: 5.*
  • PHP version: 5.3
Re: Importing contacts Error line 1048
April 03, 2013, 11:00:24 am
I cannot upload the data here, since it is trusted data, but here is some fake data:

Custom field created, Integer Yes Or no. fieldname: example_field in custom profile

Now goto; import Contacts:
Organization -> subtype: customsubtype

  • first fields contain titles
  • Update contacts


Not sure if update contacts was checked, but I thought it was.

CSV looks like:
OrginazationName,example_field,example_field notes
Testname,Yes,here more info
TestName2,No,here more info

step 2
match organization name.
exampe field from custom profile
second field from custom profile

[ import ]

error appears.

Changed the CSV
Testname,1,here more info
TestName2,0,here more info

Works fine, but might be good option to match values in boolean cases.










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: Importing contacts Error line 1048
April 03, 2013, 11:33:26 am

can you try it on demo (running 4.3) with your fake data please

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

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Importing contacts Error line 1048
July 01, 2013, 06:09:11 pm
same issue on import. see: http://forum.civicrm.org/index.php/topic,28675.msg125558.html#msg125558

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Importing contacts Error line 1048
July 02, 2013, 01:10:02 pm
Tried this on 4.3.3 and a 4.3.4 site.  not sure what is causing it or how to fix.  The subtlety is lost on a mortal non-programmer.  I did see in this footnote that there may be a difference in PHP 5.4: http://stackoverflow.com/questions/1873970/cannot-use-string-offset-as-an-array-in-php

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Importing contacts Error line 1048

This forum was archived on 2017-11-26.