SQL syntax error in getIncomeFinancialType function
I recently upgraded from 5.13.1 to 5.18.4 on a CiviCRM Drupal 7 site that's been around for the past 6 or 7 years. Post upgrade, I'm getting a SQL error whenever caches are cleared and when users try to add new price sets.
The issue seems to be in public static function getIncomeFinancialType() in FinancialType.php. $relationTypeId seems to be returning empty on line 186.
Here's the error:
Array
(
[callback] => Array
(
[0] => CRM_Core_Error
[1] => handle
)
[code] => -2
[message] => DB Error: syntax error
[mode] => 16
[debug_info] => SELECT id, entity_id
FROM civicrm_entity_financial_account
WHERE ( account_relationship = AND entity_table = 'civicrm_financial_type' )
ORDER BY entity_id
[nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND entity_table = 'civicrm_financial_type' )
ORDER BY entity_id' at line 4]
[type] => DB_Error
[user_info] => SELECT id, entity_id
FROM civicrm_entity_financial_account
WHERE ( account_relationship = AND entity_table = 'civicrm_financial_type' )
ORDER BY entity_id
[nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND entity_table = 'civicrm_financial_type' )
ORDER BY entity_id' at line 4]
[to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT id, entity_id
FROM civicrm_entity_financial_account
WHERE ( account_relationship = AND entity_table = 'civicrm_financial_type' )
ORDER BY entity_id
[nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND entity_table = 'civicrm_financial_type' )
ORDER BY entity_id' at line 4]"]
)
Any suggestions for how to fix? I initially thought there was a schema problem, but am relatively sure that's not it. Setting $relationTypeId to '1' seems to keep the error from throwing on cache clear, but doesn't fix the price set problem.