Deleting an item from a Contact History throws exception. #1935

Open
opened 2026-02-20 15:17:31 -05:00 by deekerman · 7 comments
Owner

Originally created by @jobst on GitHub (May 24, 2017).

Cannot delete an item from the history, it throws an exceptions.
Using the output of a suitecrm instance running on a PHP 7.1.2 host as this is way more informative:

[24-May-2017 15:36:48 Australia/Melbourne] PHP Notice: Undefined property: Contact::$get_unlinked_email_query in SUITECRM/include/generic/DeleteRelationship.php on line 90
[24-May-2017 15:36:48 Australia/Melbourne] PHP Notice: Trying to get property of non-object in SUITECRM/include/generic/DeleteRelationship.php on line 90
[24-May-2017 15:36:48 Australia/Melbourne] PHP Notice: Trying to get property of non-object in SUITECRM/include/generic/DeleteRelationship.php on line 90
[24-May-2017 15:36:48 Australia/Melbourne] PHP Notice: Undefined property: Contact::$get_unlinked_email_query in SUITECRM/include/generic/DeleteRelationship.php on line 92
[24-May-2017 15:36:48 Australia/Melbourne] PHP Fatal error: Uncaught Error: Call to a member function delete() on null in SUITECRM/include/generic/DeleteRelationship.php:92
Stack trace:
#0 SUITECRM/include/MVC/Controller/SugarController.php(928): require_once()
#1 SUITECRM/include/MVC/Controller/SugarController.php(394): SugarController->handleActionMaps()
#2 SUITECRM/include/MVC/Controller/SugarController.php(307): SugarController->process()
#3 SUITECRM/include/MVC/SugarApplication.php(105): SugarController->execute()
#4 SUITECRM/index.php(54): SugarApplication->execute()
#5 {main}
thrown in SUITECRM/include/generic/DeleteRelationship.php on line 92

Issue

This has been tried on PHP7.1.2 and 5.6.30 so it's not PHP related but also not Theme related as I tried it in 3 different themes Suite [7|P|R].

When clicking on the right dialog box (remove function) to remove an item a confirm box ask whether to do this, clicking yes will make all history disappear (as an error occurs in the script) and nothing happens.
A refresh of the page will show the list as it was, the item was NOT deleted.

Expected Behavior

Item deleted

Actual Behavior

Item still there

Possible Fix

too many other things to do.

Steps to Reproduce

  1. open contacts
  2. select on in the list
  3. scroll to history
  4. select the dialog box on the far right of one of the items in the list
  5. click remove
    6 history list gone but item still there after refresh

Context

cant delete anything.

Your Environment

  • SuiteCRM Version used: 7.8.2
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): N/A
  • Environment name and version (e.g. MySQL, PHP 7): 7.1.2 and 5.6.30
  • Operating System and version (e.g Ubuntu 16.04): N/A
Originally created by @jobst on GitHub (May 24, 2017). <!--- Provide a general summary of the issue in the **Title** above --> <!--- Before you open an issue, please check if a similar issue already exists or has been closed before. ---> Cannot delete an item from the history, it throws an exceptions. Using the output of a suitecrm instance running on a PHP 7.1.2 host as this is way more informative: [24-May-2017 15:36:48 Australia/Melbourne] PHP Notice: Undefined property: Contact::$get_unlinked_email_query in SUITECRM/include/generic/DeleteRelationship.php on line 90 [24-May-2017 15:36:48 Australia/Melbourne] PHP Notice: Trying to get property of non-object in SUITECRM/include/generic/DeleteRelationship.php on line 90 [24-May-2017 15:36:48 Australia/Melbourne] PHP Notice: Trying to get property of non-object in SUITECRM/include/generic/DeleteRelationship.php on line 90 [24-May-2017 15:36:48 Australia/Melbourne] PHP Notice: Undefined property: Contact::$get_unlinked_email_query in SUITECRM/include/generic/DeleteRelationship.php on line 92 [24-May-2017 15:36:48 Australia/Melbourne] PHP Fatal error: Uncaught Error: Call to a member function delete() on null in SUITECRM/include/generic/DeleteRelationship.php:92 Stack trace: #0 SUITECRM/include/MVC/Controller/SugarController.php(928): require_once() #1 SUITECRM/include/MVC/Controller/SugarController.php(394): SugarController->handleActionMaps() #2 SUITECRM/include/MVC/Controller/SugarController.php(307): SugarController->process() #3 SUITECRM/include/MVC/SugarApplication.php(105): SugarController->execute() #4 SUITECRM/index.php(54): SugarApplication->execute() #5 {main} thrown in SUITECRM/include/generic/DeleteRelationship.php on line 92 #### Issue <!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug --> This has been tried on PHP7.1.2 and 5.6.30 so it's not PHP related but also not Theme related as I tried it in 3 different themes Suite [7|P|R]. When clicking on the right dialog box (remove function) to remove an item a confirm box ask whether to do this, clicking yes will make all history disappear (as an error occurs in the script) and nothing happens. A refresh of the page will show the list as it was, the item was NOT deleted. #### Expected Behavior <!--- Tell us what should happen --> Item deleted #### Actual Behavior <!--- Tell us what happens instead --> Item still there #### Possible Fix <!--- Not obligatory, but suggest a fix or reason for the bug --> too many other things to do. #### Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug include code to reproduce, if relevant --> 1. open contacts 2. select on in the list 3. scroll to history 4. select the dialog box on the far right of one of the items in the list 5. click remove 6 history list gone but item still there after refresh #### Context <!--- How has this bug affected you? What were you trying to accomplish? --> <!--- If you feel this should be a low/medium/high priority then please state so --> cant delete anything. #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.8.2 * Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): N/A * Environment name and version (e.g. MySQL, PHP 7): 7.1.2 and 5.6.30 * Operating System and version (e.g Ubuntu 16.04): N/A
Author
Owner

@SohanTirpude commented on GitHub (May 24, 2017):

I am unable to recreate the scenario, as it is working fine on my side.

@SohanTirpude commented on GitHub (May 24, 2017): I am unable to recreate the scenario, as it is working fine on my side.
Author
Owner

@Dillon-Brown commented on GitHub (May 24, 2017):

@jobst I was able to replicate this by quick composing an email through the activities subpanel and changing the "related to" field to "none". However I am unable to replicate this with any other record type.

Can you confirm if this is the same on your end? or are emails with contacts/notes causing the same issue?

@Dillon-Brown commented on GitHub (May 24, 2017): @jobst I was able to replicate this by quick composing an email through the activities subpanel and changing the "related to" field to "none". However I am unable to replicate this with any other record type. Can you confirm if this is the same on your end? or are emails with contacts/notes causing the same issue?
Author
Owner

@jobst commented on GitHub (May 24, 2017):

@Dillon-Brown I am trying to figure this one out, too:

  • whether it's me or the code - due to the changes or not I made yet (but still need to) coz of #3262
  • whether it is the utility I am using to archive the emails
  • or whether the chain of events is incorrect and/or my understanding
    Luckily you were able to find ONE way to replicate this which make my debugging easier ...
@jobst commented on GitHub (May 24, 2017): @Dillon-Brown I am trying to figure this one out, too: - whether it's me or the code - due to the changes or not I made yet (but still need to) coz of #3262 - whether it is the utility I am using to archive the emails - or whether the chain of events is incorrect and/or my understanding Luckily you were able to find ONE way to replicate this which make my debugging easier ...
Author
Owner

@jobst commented on GitHub (May 25, 2017):

@Dillon-Brown I was able to delete some but not others (mostly old ones), however I am able to delete a newly created one ... you might want to check older ones?

I do not understand why this happened. I know the cause - the relationship info IS missing in the database, but I cannot look back in time to see why it was not created and/or whether is was a problem of the rest interface OR the application entering the data OR an upgrade of SugarCRM or SuiteCRM.

One thing that should be if this happens: it should be able to display an error message to the user and what can be done to still delete this information. You can delete this information by clicking on the subject line then delete it there.

If you look at the code in SUITECRM/include/generic/DeleteRelationship.php on line 91
$focus->$linked_field->delete($record,$linked_id);
if the $linked_field does not exist or is null it throws an exception and wipes the history list. Really before the function is CALLED it should be checked whether the object exist.

Depending on the browser and the setting in the php.ini it will either display the thrown error (chrome) or nothing (firefox) ... but in any case the history is gone - this should not be if the OBJECT is not defined but simply alert the user to the missing info.

@jobst commented on GitHub (May 25, 2017): @Dillon-Brown I was able to delete some but not others (mostly old ones), however I am able to delete a newly created one ... you might want to check older ones? I do not understand why this happened. I know the cause - the relationship info IS missing in the database, but I cannot look back in time to see why it was not created and/or whether is was a problem of the rest interface OR the application entering the data OR an upgrade of SugarCRM or SuiteCRM. One thing that should be if this happens: it should be able to display an error message to the user and what can be done to still delete this information. You can delete this information by clicking on the subject line then delete it there. If you look at the code in SUITECRM/include/generic/DeleteRelationship.php on line 91 $focus->$linked_field->delete($record,$linked_id); if the $linked_field does not exist or is null it throws an exception and wipes the history list. Really before the function is CALLED it should be checked whether the object exist. Depending on the browser and the setting in the php.ini it will either display the thrown error (chrome) or nothing (firefox) ... but in any case the history is gone - this should not be if the OBJECT is not defined but simply alert the user to the missing info.
Author
Owner

@dgailwhitt commented on GitHub (Mar 11, 2018):

This issue is as a result of the enhancement of the list of emails in the History sub-panel.

The list of Emails that you see in the History section are "enriched" with a query/function (get_unlinked_email_query) that returns additional historical information related to the Lead/Account/Contact/Prospect. The relationship is established due to the fact that the same email address is found somewhere in the email. So you could be seeing linked and unlinked emails in the History list.
When you try to remove the link for any of these unlinked emails, an error occurs because it is not really linked.

So I am suggesting the following possible solutions...

  1. grey out the Remove option on unlinked emails in the History subpanel and perhaps identify those emails as unlinked/related
    or
  2. add logic to DeleteRelationship to handle this problem more gracefully/do not fail
    or
  3. remove the logic that enhances the email history with unlinked/related emails
@dgailwhitt commented on GitHub (Mar 11, 2018): This issue is as a result of the enhancement of the list of emails in the History sub-panel. The list of Emails that you see in the History section are "enriched" with a query/function (get_unlinked_email_query) that returns additional historical information related to the Lead/Account/Contact/Prospect. The relationship is established due to the fact that the same email address is found somewhere in the email. So you could be seeing linked and unlinked emails in the History list. When you try to remove the link for any of these unlinked emails, an error occurs because it is not really linked. So I am suggesting the following possible solutions... 1. grey out the Remove option on unlinked emails in the History subpanel and perhaps identify those emails as unlinked/related or 2. add logic to DeleteRelationship to handle this problem more gracefully/do not fail or 3. remove the logic that enhances the email history with unlinked/related emails
Author
Owner

@pgorod commented on GitHub (Sep 5, 2018):

I have someone in the Forums getting this problem. I tried in my test system and I can reproduce. I don't have time to bugfix and debug, though. But @Dillon-Brown tell me if you think there's anything I can do for this issue...

@pgorod commented on GitHub (Sep 5, 2018): I have someone in the Forums getting this problem. I tried in my test system and I can reproduce. I don't have time to bugfix and debug, though. But @Dillon-Brown tell me if you think there's anything I can do for this issue...
Author
Owner

@Kevconry commented on GitHub (Mar 10, 2023):

Can't replicate in 7.13.2. When I remove the record from the history subpanel it remains removed after the refresh
please re-raise or get in touch if you are still having this issue

@Kevconry commented on GitHub (Mar 10, 2023): Can't replicate in 7.13.2. When I remove the record from the history subpanel it remains removed after the refresh please re-raise or get in touch if you are still having this issue
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#1935
No description provided.