Ignoring exception thrown by nullHandler: -2, DB Error: syntax error
Advanced search can result in DB errors; it appears the bug is in CRM/Core/PrevNextCache/Sql.php
Steps to reproduce:
- Fire up CiviCRM 5.18.4
- Visit advanced search @ civicrm/contact/search/advanced
- Click Address Fields and enter 1600 under the Street Address field.
- Click Search; search completes successfully.
- Check your error log for "$backTrace = #0..." and "Ignoring exception thrown by nullHandler: -2, DB..."
I think what happens is %
is automatically tacked on to make it a "LIKE" search, and this results in %1600
in the query.. the %1 parameter is then filled, resulting in invalid SQL.
The DB error is e.g.:
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 'civicrm search 9dcac50894b9b820a311612b44525018_1779'600%' ) AND (contact_a.is_' at line 2
The query is e.g.:
INSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)
SELECT DISTINCT 'civicrm search 9dcac50894b9b820a311612b44525018_1779', contact_a.id, contact_a.sort_name FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) WHERE ( civicrm_address.street_address LIKE ''civicrm search 9dcac50894b9b820a311612b44525018_1779'600%' ) AND (contact_a.is_deleted = 0) LIMIT 0, 500