oroinc / platform

Main OroPlatform package with core functionality.
Other
627 stars 351 forks source link

3.1.0-rc Exception - EmailActivityListProvider::getGroupedEntities "getThread() on null" #880

Open fyrye opened 5 years ago

fyrye commented 5 years ago

Environment: oroinc/crm-application 3.1.0-RC (new install) PHP 7.2.13

Issue: When attempting to view a User account, an error message is displayed There was an error performing the requested operation. Please try again or contact us for assistance..

Steps:

Received:

[2018-12-17 09:27:10] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Call to a member function getThread() on null" at /home/user/example.com/vendor/oro/platform/src/Oro/Bundle/EmailBundle/Provider/EmailActivityListProvider.php line 362 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function getThread() on null at /home/user/example.com/vendor/oro/platform/src/Oro/Bundle/EmailBundle/Provider/EmailActivityListProvider.php:362)"} []

Notes: Attempting to delete the user displays You do not have permission to perform this action. I believe this is due to the assigned relationship of contacts/accounts to the user.

Issue appears to be related to the Activity List and User relationships associated with the synchronized emails.

After removing the activity list entries of the synchronized emails from the database, the issue was resolved.

yaroslavbr commented 5 years ago

Hi, @fyrye . Thank you for reporting the issue! It is possible that problem is in imported data. Could you please provide your obfuscated csv file or some similar sample so we can understand what data was processed? Were there any errors during the import process? It will be great if you can attach log file as well. Thanks in advance.

fyrye commented 5 years ago

@yaroslavbr The issue appears to be related to the relationship table of the activity list and the synchronized emails.

I had removed the email synchining from my account afterward, but the activity list relationship still remained.

Several of the emails I synchronized contained the user's email as a recipient, and assume that is how it was associated in the activity list.

I determined the relationship by querying

SELECT alc.user_id, MAX(alc.activitylist_id)
FROM oro_rel_c3990ba62da17977270bd6 AS alc
GROUP BY alc.user_id

All of the listed user_id values were affected by the issue. Referencing the activity list of one of the affected users, showed the synchronized email.

I went through and deleted the activity list entries of the synchronized emails, and the issue was resolved.

I removed the activity list entries by performing

DELETE oal
FROM oro_activity_list AS oal
LEFT JOIN oro.email AS oe
ON oe.id = oal.related_activity_id
AND oal.related_activity_class = 'Oro\Bundle\EmailBundle\Entity\Email' 
WHERE oe.id IS NULL;

Updated initial comment to reflect my findings.

jneto81 commented 5 years ago

I had the same problem. For some reason, the Activity List had some records related with emails removed from the database.

I removed from the database, the activities related with the deleted emails to fix my problem.

The main problem with this, is that the error kill the response. My suggestion is if the getThread is null, ignore the activity.