Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jobst opened this issue May 24, 2017 · 7 comments
Open

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

jobst opened this issue May 24, 2017 · 7 comments
Labels
Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Type: Bug Bugs within the core SuiteCRM codebase

Comments

@jobst
Copy link
Contributor

jobst commented 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
@Dillon-Brown Dillon-Brown added Type: Bug Bugs within the core SuiteCRM codebase Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds labels May 24, 2017
@SohanTirpude
Copy link
Contributor

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

@Dillon-Brown
Copy link
Contributor

Dillon-Brown commented 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 Dillon-Brown added Status:Requires Updates Issues & PRs which requires input or update from the author and removed Type: Bug Bugs within the core SuiteCRM codebase Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds labels May 24, 2017
@jobst
Copy link
Contributor Author

jobst commented May 25, 2017

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

@jobst
Copy link
Contributor Author

jobst commented 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.

@Dillon-Brown Dillon-Brown added Type: Bug Bugs within the core SuiteCRM codebase Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds and removed Status:Requires Updates Issues & PRs which requires input or update from the author labels May 29, 2017
@dgailwhitt
Copy link

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

@pgorod
Copy link
Contributor

pgorod commented 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...

@Kevconry
Copy link

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Type: Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

6 participants