Import Contacts Error

Hi everyone!

I’m getting a PHP error message when trying to import contacts from a CSV file.

The error is the following:

NOTICE: [8] Trying to get property of non-object on line 428 in file /var/www/html/suitecrmgcoop/modules/Contacts/Contact.php

I’m using version 7.9.11

Thank you!

If that error is shown on screen, then just turn it off.

Your error_reporting should be set to E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED in php.ini.

You can also try changing display_errors to false.

Notices aren’t really errors, so this shouldn’t be a problem.

Tell me if that fixes the import for you.

Actually, both options (error_reporting and display_errors) are set as you said. Nevertheless, it kept throwing this notice and interrupting import on about 10% of progress.

So I checked the line 428 on the script Contacts.php. It goes like this:

// Set campaign name if there is a campaign id
		if( !empty($this->campaign_id)){

			$camp = new Campaign();
		    $where = "'{$this->campaign_id}'";
		    $campaign_list = $camp->get_full_list("", $where, true);
		    $this->campaign_name = $campaign_list[0]->name;

The block above starts at line 422 till 429. As commented by devs, it sets campaign_name property only if there is a campaign id. None of my contact has a campaign id, as we don’t use this feature. In the Contacts CVS exported from PHPMyAdmin, some of the lines had this field empty and others NULL.

So I changed importing parameters not to map campaign_id field when importing contacts. Guess wot??? It worked!!!

Finally, I performed 2 tests: importing a dummy CVS, this time mapping campaign_id field. The first test would have campaign_id = NULL and the second campaign_id = ‘’ (empty). I thought maybe the lines with NULL would be the problem. But no. Both were imported correctly.

It’s strange. I will try again in order to find where was the problem. The weirdest thing is: why did it keep showing that notice even after I deactivated it in php.ini? After changing the config option, I rebooted.

Thank you for your time

If you can reproduce your bug in the live demo, with as short a CSV file as possible, and then open an issue on GtiHub describing it and providing that CSV, the developers can have a look at this.

I’ll do my best. The CSV with troubles had 11k contacts, more than 4MB.

Thanks. There’s a technique called “bisection” that I once learned for narrowing down the source of problems that works like this:

  • Split your data in half, test which half gives the error.
  • then split that half in half, test which half gives the error.
  • repeat until you narrow it down to one guilty row

In your case, that’s 14 iterations:

It’s boring to do, but it’s not endless, or hopeless :slight_smile:

1 Like

I think I just crashed demo server!!!

First, I tried my list with 1200 contacts. I knew the notice appeared near line 1000. It appeared on demo!!! So, I started your advice: bisection. But first I wanted to delete all contacts in order to avoid duplicates (if I used the duplicates find in SuiteCRM maybe the result would be different). There were some demo contacts, I think about 100. I deleted it all. During this process, server threw 504 Gateway Time-out.

Now I can’t login. It keeps throwing 504.

I’m really sorry… I didn’t mean to crash it!!! :frowning: :frowning:

Don’t worry, that is probably just the Demo refreshing itself. It happens every hour (I believe) and you should be able to use it again after a few minutes.

The whole thing is reset once in a while to make sure people don’t mess it up too much. You probably just had the bad luck to be using it at that time. Try again in a few minutes… :slight_smile:

Hahhaha great to know that!

I could reach the problematic register! I’m filling an issue on GitHub. Thank’s for your time. Tchau! See you next trouble… :stuck_out_tongue:

Here it is:

1 Like