CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 3.4 and 4.0 Releases Testing »
  • Dedupe - apostrophe in contact name causes database error
Pages: [1]

Author Topic: Dedupe - apostrophe in contact name causes database error  (Read 2523 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Dedupe - apostrophe in contact name causes database error
February 25, 2011, 02:13:16 pm
3.4.alpha1

When I attempt to dedupe contacts I get a database error. It is due to apostrophe's in a contact's names which interfere with the MySQL syntax.

Here is my sanitised error message ...

Quote
Database Error Code: 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 '*****";s:5:"dstID";s:5:"*****";s:7:"dstName";s:13:"***** O'*****";s:6:"weight";s' at line 130, 1064
Additional Details:

Array
(
    [callback] => Array
        (
            [ 0 ] => CRM_Core_Error
            [ 1 ] => handle
        )

    [ code ] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cacheKey, data ) VALUES

Here is the sanitised line that causes the problem ...

Quote
  ( 'civicrm_contact', *****, *****, 'merge Individual_8_0', 'a:6:{s:5:"srcID";s:5:"*****";s:7:"srcName";s:13:"***** O'*****";s:5:"dstID";s:5:"*****";s:7:"dstName";s:13:"***** O'*****";s:6:"weight";s:2:"20";s:8:"canMerge";b:1;}' ) ,

If a contact has a name containing an apostrophe, that is interpreted by MySQL as a string delimiter. Names need to be quoted to avoid this.

Ken

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Dedupe - apostrophe in contact name causes database error
February 25, 2011, 02:38:43 pm

can you please file an issue, we'll fix this for the next release. its a serialized array which needs to be escaped

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Dedupe - apostrophe in contact name causes database error
February 25, 2011, 06:12:31 pm
Created issue CRM-7637

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Dedupe - apostrophe in contact name causes database error
March 10, 2011, 08:41:49 pm
3.4.alpha2

This fix resolves my issue. Thanks!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 3.4 and 4.0 Releases Testing »
  • Dedupe - apostrophe in contact name causes database error

This forum was archived on 2017-11-26.