jjwdesign / JJWDesign-Google-Maps

SugarCRM Google Maps Integration: Accounts, Contacts, Leads, Opportunities, Cases and Projects (records) can be mapped. Multiple records can be mapped, instead of just one record at a time. Records can be mapped from a module's listing or by distance.
http://www.sugarforge.org/projects/jjwgooglemaps
GNU Affero General Public License v3.0
20 stars 22 forks source link

Nasty bug because of logging with print_r #9

Open pgorod opened 8 years ago

pgorod commented 8 years ago

Hi there Jeff. Let me start by thanking you for all your work and this code you're sharing,

In the past few days I ran into serious problems in SuiteCRM 7.4.1 and it turns out to be related to one of your files - even though I am not using maps at all, your hooks were running and creating problems.

I am writing an "Import" script that creates hundreds of records, so that put some extra pressure on the hooks, causing the bug to become apparent.

Basically, something in my set up is causing your hooks in AccountsJjwg_MapsLogicHook.php to be called with arguments that are huge. These get logged with print_r causing thousands of lines to be dumped into the sugarcrm.log. Then PHP freaks out and exits, and I had a hard time figuring this out because it can break in different places! So, when I was stepping through the code in Eclipse, it would have enough time to write the log, and work; but when I let it run by itself, it would quickly get into problems.

I'm not sure what is special with my data, but it might be that I have symmetrical relationships on a custom contacts-to-contacts module. I'm modelling families, so a father contact will have a link to a son contact, and the son will have a link to the father. Maybe this comes up in the hook arguments as an endless loop of pointers. And print_r gets lost printing all that...

What I do know is that by removing these lines (watch out, you have them in several places in your code)... $GLOBALS['log']->info(METHOD.' $arguments: '.print_r($arguments, true));

... by removing this, suddenly everything started working well, and also I solved the huge performance problem I was having (like 3 seconds to save a contact bean).

I believe I should warn about this in the SuiteCRM forums but I came here first so you can be part of the solution and we can present this as a solved issue. Can you please comment on this and tell me how we can get this fix into the next SuiteCRM update?

Thanks in advance.

pgorod commented 8 years ago

This issue is now taken care of in SuiteCRM codebase: https://github.com/salesagility/SuiteCRM/issues/884