Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-16289

Remove special characters from log_civicrm_case.case_type_id data during upgrade

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.6
    • Fix Version/s: 4.6.1
    • Component/s: None
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      Add logic to 4.6 upgrade to remove special characters from log_civicrm_case.case_type_id table before running alter table (fixSchemaDifferences) if that table exists.

      NOTE: UPDATE statements are not allowed on tables using the ARCHIVE engine (which all log_* tables use). Hence, the upgrade needs to change the engine on that log table from ARCHIVE to InnoDB, do the update, and then change it back.

      NOTE: Sites that have already upgraded from 4.4 would already have been affected by this error and the case_type_id in their log row(s) is lost. I don't think there's reasonable anything we can do about that.

      — Original Post ----
      I'm seeing an error on the rebuild triggers for the log_civicrm_case table after 4.6 upgrade

      When I run the mysql through the UI it completes but gives a warning and the value '1' in case_type_id is converted to 0 rather than 1.

      ALTER TABLE log_civicrm_case MODIFY `case_type_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to civicrm_case_type.id';

      #0 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/Error.php(182): CRM_Core_Error::backtrace()
      #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
      #2 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
      #3 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/DB.php(976): PEAR_Error->PEAR_Error("DB Error: unknown error", -1, 16, (Array:2), "ALTER TABLE `cany_drupal`.log_civicrm_case MODIFY `case_type_id` int(10) un...")
      #4 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-1, 16, (Array:2), "ALTER TABLE `cany_drupal`.log_civicrm_case MODIFY `case_type_id` int(10) un...")
      #5 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -1, NULL, NULL, "ALTER TABLE `cany_drupal`.log_civicrm_case MODIFY `case_type_id` int(10) un...", "DB_Error", TRUE)
      #6 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/DB/mysql.php(899): DB_common->raiseError(-1, NULL, NULL, NULL, "1366 ** Incorrect integer value: '1' for column 'case_type_id' at row 1")
      #7 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/DB/mysql.php(328): DB_mysql->mysqlRaiseError()
      #8 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("ALTER TABLE `cany_drupal`.log_civicrm_case MODIFY `case_type_id` int(10) un...")
      #9 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/DB/DataObject.php(2442): DB_common->query("ALTER TABLE `cany_drupal`.log_civicrm_case MODIFY `case_type_id` int(10) un...")
      #10 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/DB/DataObject.php(1634): DB_DataObject->_query("ALTER TABLE `cany_drupal`.log_civicrm_case MODIFY `case_type_id` int(10) un...")
      #11 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/DAO.php(325): DB_DataObject->query("ALTER TABLE `cany_drupal`.log_civicrm_case MODIFY `case_type_id` int(10) un...")
      #12 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/DAO.php(1179): CRM_Core_DAO->query("ALTER TABLE `cany_drupal`.log_civicrm_case MODIFY `case_type_id` int(10) un...", TRUE)
      #13 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Logging/Schema.php(244): CRM_Core_DAO::executeQuery("ALTER TABLE `cany_drupal`.log_civicrm_case MODIFY `case_type_id` int(10) un...")
      #14 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Logging/Schema.php(307): CRM_Logging_Schema->fixSchemaDifferencesFor("civicrm_case", (Array:3), FALSE)
      #15 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Logging/Schema.php(207): CRM_Logging_Schema->fixSchemaDifferencesForAll()
      #16 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Logging/Schema.php(190): CRM_Logging_Schema->fixSchemaDifferences(TRUE)
      #17 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Admin/Form/Setting/Miscellaneous.php(170): CRM_Logging_Schema->enableLogging()
      #18 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/Form.php(345): CRM_Admin_Form_Setting_Miscellaneous->postProcess()
      #19 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/StateMachine.php(164): CRM_Core_Form->mainProcess()
      #20 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php(61): CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_Setting_Miscellaneous), "next", "Next")
      #21 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_Setting_Miscellaneous), "next")
      #22 /var/www/site/my.site.org/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Setting_Miscellaneous), "next")
      #23 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/Controller.php(353): HTML_QuickForm_Page->handle("next")
      #24 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(115): CRM_Core_Controller->run()
      #25 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/Invoke.php(286): CRM_Utils_Wrapper->run("CRM_Admin_Form_Setting_Miscellaneous", "Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)", NULL)
      #26 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem((Array:13))
      #27 /var/www/site/my.site.org/sites/all/modules/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke((Array:4))
      #28 /var/www/site/my.site.org/sites/all/modules/civicrm/drupal/civicrm.module(489): CRM_Core_Invoke::invoke((Array:4))
      #29 [internal function](): civicrm_invoke("admin", "setting", "misc")
      #30 /var/www/site/my.site.org/includes/menu.inc(519): call_user_func_array("civicrm_invoke", (Array:3))
      #31 /var/www/site/my.site.org/index.php(21): menu_execute_active_handler()

      Note that in this case I'm simply dropping & recreating the log_civicrm_case table as the data is only test data.

      If you can't replicate in a different mysql scenario then go ahead & close because I've already lost the data to replicate it here

        Attachments

          Activity

            People

            • Assignee:
              dgg David Greenberg
              Reporter:
              eileen Eileen McNaughton
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: