Contact: Database failure. Please refer to suitecrm.log for details

Dear all,

when opening an opportunity I am getting the following error in the contacts:
Database failure. Please refer to suitecrm.log for details.
image

In the logs I see the following query failing:

SELECT contacts.id ,  contacts.first_name ,  contacts.last_name ,  contacts.salutation ,  LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),IFNULL(contacts.last_name,'')))) as name, account_name , 
account_id, opportunity_role_fields , opportunity_id ,  contacts.phone_work ,  contacts.assigned_user_id  ,  contacts.panel_name  FROM contacts  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c  INNER JOIN  opportunities_contacts ON contacts.id=opportunities_contacts.contact_id AND opportunities_contacts.opportunity_id='30e3af0e-xxx-09a9-dc71-63a41c20012c' AND opportunities_contacts.deleted=0

When I execute this on the database, I am getting:
#1054 - Unknown column ‘account_name’ in ‘field list’

Actually the folllowing columns do not exist in contacts:

  • contacts.panel_name
  • account_name
  • account_id

Do I need to look at the source code now or is there any other way to fix this?

I am using the following versions:

  • SuiteCRM 7.13
  • Mysql 8
  • PHP 7.4

Hello @5v3n50mm3rf3ld

This is precisely the same issue and the fix is the same.
Note the error in the subpanel at the bottom of the screenshot.

This issue impacts subpanels in every module as all the subpanels use SugarBean.php when pulling data. Where the user first encounters the error depends on what part of the CRM they use after the MySQL environment on their server is updated.

To fix:
In SuiteCRM/data/SugarBean.php

Replace

$final_query = ‘(’ . $tmp_final_query . ‘)’;

With

$final_query =  $tmp_final_query ;

The $final_query variable is used further in the code

I hope this is helpful.

Thanks.

2 Likes

It would help if you posted your SuiteCRM version, PHP version, MySQL version (did you recently upgrade to 8.0?)

Maybe you’re getting this known issue

The telling sign would be this message somewhere in your logs:

`MySQL error 1250: Table ‘contacts’ from one of the SELECTs cannot be used in global ORDER clause ````

Don’t comment out line 876

Replace

$final_query = ‘(’ . $tmp_final_query . ‘)’;

With

$final_query =  $tmp_final_query ;

The $final_query variable is used further in the code

2 Likes