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

upgrading to (unreleased) 4.3.6 gets sql error on some sites

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.3.6
    • Fix Version/s: 4.3.6
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      Out of about 70 sites, we had two with this error:

      Exception: "A fatal error was triggered: is not of type String"
      #0 /var/aegir/platforms/master-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/DAO.php(1003): CRM_Core_Error::fatal(" is not of type String")
      #1 /var/aegir/platforms/master-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/DAO.php(903): CRM_Core_DAO::composeQuery("UPDATE civicrm_line_item cli\nLEFT JOIN civicrm_financial_item cfi ON cli.id ...", (Array:6), TRUE)
      #2 /var/aegir/platforms/master-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Upgrade/Incremental/php/FourThree.php(995): CRM_Core_DAO::executeQuery("UPDATE civicrm_line_item cli\nLEFT JOIN civicrm_financial_item cfi ON cli.id ...", (Array:6))
      #3 [internal function](): CRM_Upgrade_Incremental_php_FourThree::updateLineItemData(Object(CRM_Queue_TaskContext), "4.3.6")
      #4 /var/aegir/platforms/master-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Queue/Task.php(79): call_user_func_array((Array:2), (Array:2))
      #5 /var/aegir/platforms/master-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Queue/Runner.php(186): CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))
      #6 /var/aegir/platforms/master-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Queue/Runner.php(148): CRM_Queue_Runner->runNext()
      #7 /var/aegir/platforms/master-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Upgrade/Headless.php(65): CRM_Queue_Runner->runAll()
      #8 /home/jamie/projects/ptp/repos/provision_civicrm/civicrm.drush.inc(543): CRM_Upgrade_Headless->run()
      #9 [internal function](): drush_civicrm_upgrade_db()
      #10 /usr/share/drush/includes/command.inc(134): call_user_func_array("drush_civicrm_upgrade_db", (Array:0))
      #11 /usr/share/drush/includes/command.inc(806): _drush_invoke_args("civicrm-upgrade-db", (Array:0), "civicrm")
      #12 [internal function](): drush_command()
      #13 /usr/share/drush/includes/command.inc(214): call_user_func_array("drush_command", (Array:0))
      #14 /usr/share/drush/drush.php(101): drush_dispatch((Array:22))
      #15 /usr/share/drush/drush.php(41): drush_main()
      #16

      {main}

      #

      It seems to happen if the label is set to NULL in the database.

      Here's some sample data from an affected site:

      mysql> SELECT cc.id contribution_id, cc.contribution_recur_id,
      -> cc.financial_type_id contribution_financial_type,
      -> cli.financial_type_id line_financial_type_id,
      -> cli.price_field_id, cli.price_field_value_id, cli.label, cli.id line_item_id,
      -> cfi.financial_account_id
      -> FROM `civicrm_line_item` cli
      -> LEFT JOIN civicrm_contribution cc ON cc.id = cli.entity_id
      -> LEFT JOIN civicrm_financial_item cfi ON cfi.entity_id = cli.id
      -> LEFT JOIN civicrm_price_field cpf ON cpf.id = cli.price_field_id
      -> LEFT JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id
      -> LEFT JOIN civicrm_price_field_value cpfv ON cpfv.id = cli.price_field_value_id
      -> WHERE cfi.entity_table = 'civicrm_line_item'
      -> AND cli.entity_table = 'civicrm_contribution'
      -> AND cps.is_quick_config = 1 AND cc.contribution_recur_id IS NOT NULL
      -> ORDER BY cli.id;
      ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      contribution_id contribution_recur_id contribution_financial_type line_financial_type_id price_field_id price_field_value_id label line_item_id financial_account_id

      ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      6880 1 1 1 13 31 NULL 6836 3
      6880 1 1 1 13 31 NULL 6836 3
      6880 1 1 1 13 31 NULL 6836 3
      6880 1 1 1 13 31 NULL 6836 1
      6905 1 1 1 1 1 Contribution Amount 6862 1

      ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      5 rows in set (0.11 sec)

      mysql> select * from civicrm_line_item where id = 6862;
      ------------------------------------------------------------------------------------------------------------------------------------------------------------------+

      id entity_table entity_id price_field_id label qty unit_price line_total participant_count price_field_value_id deductible_amount financial_type_id

      ------------------------------------------------------------------------------------------------------------------------------------------------------------------+

      6862 civicrm_contribution 6905 1 Contribution Amount 1 10.00 10.00 NULL 1 0.00 1

      ------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.00 sec)

      mysql>

      The fix for the error is trivial. Something like:

      — /var/aegir/platforms/ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Upgrade/Incremental/php/FourThree.php 2013-08-28 11:49:04.000000000 -0400
      +++ /var/aegir/platforms/master-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Upgrade/Incremental/php/FourThree.php 2013-09-04 14:41:41.000000000 -0400
      @@ -984,11 +984,11 @@
      WHERE cfi.entity_table = 'civicrm_line_item'
      AND cli.entity_table = 'civicrm_contribution' AND cli.id IN (" . implode(',', $value). ');';
      $params = array(

      • 1 => array($financialTrxn[$key]['label'], 'String'),
        + 1 => array(strval($financialTrxn[$key]['label']), 'String'),
        2 => array($financialTrxn[$key]['price_field_id'], 'Integer'),
        3 => array($financialTrxn[$key]['price_field_value_id'], 'Integer'),
        4 => array($financialTrxn[$key]['financial_account_id'], 'Integer'),
      • 5 => array($financialTrxn[$key]['label'], 'String'),
        + 5 => array(str($financialTrxn[$key]['label']), 'String'),
        6 => array($dao->contribution_financial_type, 'Integer'),
        );
        CRM_Core_DAO::executeQuery($sql, $params);

      But... wanted to see if this was an indicator of something wrong with the data that the code should be checking for. For example, in the data above, it looks like the problem is that the row with a NULL label appears before the row with the non NULL label

        Attachments

          Activity

            People

            • Assignee:
              dgg David Greenberg
              Reporter:
              jamie Jamie McClelland
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: