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) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Error when disabling an 'employed by' relationship
Pages: [1]

Author Topic: Error when disabling an 'employed by' relationship  (Read 675 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
Error when disabling an 'employed by' relationship
January 03, 2011, 06:41:16 pm
I've found an error in 3.3.1 that is reproducible on the demo site. I think I've identified the offending code. Here's how to reproduce:

  • create a 'employee of' relationship for an individual
  • 'edit' the relationship
  • uncheck the 'Enabled?' flag
  • click on 'save relationship' and get the following error...

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 '' at line 3, 1064
Additional Details:

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

    [code ] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => UPDATE civicrm_contact
SET organization_name=NULL, employer_id = NULL
WHERE 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 '' at line 3]
    [type] => DB_Error
    [user_info] => UPDATE civicrm_contact
SET organization_name=NULL, employer_id = NULL
WHERE 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 '' at line 3]
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="UPDATE civicrm_contact
SET organization_name=NULL, employer_id = NULL
WHERE 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 '' at line 3]"]
)

The workaround is to disable the relationship by setting the end date.

It seems to be related to the following code on line 505ff in CRM/Contact/Form/Relationship.php ...

Code: [Select]
           //if relationship type change and previously it was
            //employer / emplyee relationship with current employer
            //than clear the current employer. CRM-3235.
            if ( ( CRM_Utils_Array::value( 'current_employee_id', $this->_values ) &&
                  $relationshipTypeId != $this->_values['relationship_type_id'] ) ||
                 ( ! $params['is_active'] ) ) {
                require_once 'CRM/Contact/BAO/Contact/Utils.php';
                CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer( $this->_values['current_employee_id'] );
            }

This code can be called when $params['is_active'] is 'false', irrespective of whether $this->_values['current_employee_id'] has a valid value.

My backtrace is ...

Quote
Jan 03 22:41:20  [info] $backTrace = /var/www/citybibleforum/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 205
, handle,
/var/www/citybibleforum/sites/all/modules/civicrm/packages/PEAR.php, call_user_func, 931
/var/www/citybibleforum/sites/all/modules/civicrm/packages/DB.php, PEAR_Error, 968
/var/www/citybibleforum/sites/all/modules/civicrm/packages/PEAR.php, DB_Error, 564
/var/www/citybibleforum/sites/all/modules/civicrm/packages/DB/common.php, raiseError, 1903
/var/www/citybibleforum/sites/all/modules/civicrm/packages/DB/mysql.php, raiseError, 898
/var/www/citybibleforum/sites/all/modules/civicrm/packages/DB/mysql.php, mysqlRaiseError, 327
/var/www/citybibleforum/sites/all/modules/civicrm/packages/DB/common.php, simpleQuery, 1216
/var/www/citybibleforum/sites/all/modules/civicrm/packages/DB/DataObject.php, query, 2421
/var/www/citybibleforum/sites/all/modules/civicrm/packages/DB/DataObject.php, _query, 1607
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Core/DAO.php, query, 145
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Core/DAO.php, query, 868
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Contact/BAO/Contact/Utils.php, executeQuery, 391
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Contact/Form/Relationship.php, clearCurrentEmployer, 512
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Core/Form.php, postProcess, 250
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php, mainProcess, 153
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php, realPerform, 130
/var/www/citybibleforum/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/var/www/citybibleforum/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Core/Controller.php, handle, 284
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Contact/Page/View/Relationship.php, run, 215
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Contact/Page/View/Relationship.php, edit, 252
/var/www/citybibleforum/sites/all/modules/civicrm/CRM/Core/Invoke.php, run, 219
/var/www/citybibleforum/sites/all/modules/civicrm/drupal/civicrm.module, invoke, 356
, civicrm_invoke,
/var/www/citybibleforum/includes/menu.inc, call_user_func_array, 348
/var/www/citybibleforum/index.php, menu_execute_active_handler, 18
« Last Edit: January 03, 2011, 06:43:37 pm by ken »

sushant

  • I post frequently
  • ***
  • Posts: 126
  • Karma: 8
  • CiviCRM version: v3.2.x,v3.3.x v4.0.x, v4.x,trunk
  • CMS version: Drupal 6/7 ,joomla 1.5,1.6
  • MySQL version: 5.1.51
  • PHP version: 5.3.3
Re: Error when disabling an 'employed by' relationship
January 03, 2011, 09:02:20 pm
Hi ken,
Thankx for reporting.
Related issue is filed here http://issues.civicrm.org/jira/browse/CRM-7306

Sushant
CiviCRM Priority Support
http://support.civigardens.com/
http://osseed.com

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: Error when disabling an 'employed by' relationship
January 04, 2011, 03:39:21 pm
Hey! Great service!

I commented on the forums, Sushant fixes the issue, and it's released as part of 3.3.2 within 48 hours!

Nice,

Ken

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Error when disabling an 'employed by' relationship

This forum was archived on 2017-11-26.