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 »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Fatal error on Upgrade DB to 4.2.alpha1: Contributions - price_set_id NULL
Pages: [1]

Author Topic: Fatal error on Upgrade DB to 4.2.alpha1: Contributions - price_set_id NULL  (Read 637 times)

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Fatal error on Upgrade DB to 4.2.alpha1: Contributions - price_set_id NULL
November 26, 2013, 03:55:24 am
Hi,

When upgrading a 4.1.6 site to 4.2.14, we got the following error:

[Error: Upgrade DB to 4.2.alpha1: Contributions (17 => 5016)]
Exception: "A fatal error was triggered"

#0 .../drupal-7.22/sites/all/modules/civicrm/CRM/Core/DAO.php(755): CRM_Core_Error::fatal()
#1 .../drupal-7.22/sites/all/modules/civicrm/CRM/Upgrade/Incremental/php/FourTwo.php(687): CRM_Core_DAO::getFieldValue("CRM_Price_DAO_Field", NULL, "id", "price_set_id")
#2 [internal function](): CRM_Upgrade_Incremental_php_FourTwo::task_4_2_alpha1_convertContributions(Object(CRM_Queue_TaskContext), "17", 5016)
#3 .../drupal-7.22/sites/all/modules/civicrm/CRM/Queue/Task.php(79): call_user_func_array((Array:2), (Array:3))
#4 .../drupal-7.22/sites/all/modules/civicrm/CRM/Queue/Runner.php(187): CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))
#5 .../drupal-7.22/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php(44): CRM_Queue_Runner->runNext(TRUE)
#6 .../drupal-7.22/sites/all/modules/civicrm/CRM/Queue/ErrorPolicy.php(80): {closure}()
#7 .../drupal-7.22/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php(47): CRM_Queue_ErrorPolicy->call(Object(Closure))
#8 [internal function](): CRM_Queue_Page_AJAX::runNext((Array:5))
#9 .../drupal-7.22/sites/all/modules/civicrm/CRM/Core/Invoke.php(187): call_user_func((Array:2), (Array:5))
#10 .../drupal-7.22/sites/all/modules/civicrm/CRM/Core/Invoke.php(51): CRM_Core_Invoke::_invoke((Array:5))
#11 .../drupal-7.22/sites/all/modules/civicrm/drupal/civicrm.module(500): CRM_Core_Invoke::invoke((Array:5))
#12 [internal function](): civicrm_invoke("upgrade", "queue", "ajax", "runNext")
#13 .../drupal-7.22/includes/menu.inc(517): call_user_func_array("civicrm_invoke", (Array:4))
#14 .../drupal-7.22/index.php(21): menu_execute_active_handler()
#15 {main}

The error occured on this line in CRM/Upgrade/Incremental/php/FourTwo.php(687):
Code: [Select]
            $lineParams['price_field_id'] =
              CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $result->price_set_id, 'id', 'price_set_id');
$result->price_set_id was NULL, hence the error in CRM_Core_DAO::getFieldValue() .

I got past it with this change:

Code: [Select]
--- FourTwo.php.orig    2013-11-21 02:39:29.000000000 +0000
+++ FourTwo.php 2013-11-26 11:21:19.000000000 +0000
@@ -683,8 +683,11 @@
               CRM_Core_DAO::getFieldValue('CRM_Price_DAO_FieldValue', $defaults['id'], 'id', 'price_field_id');
           }
           else {
+            // Attempted fix for fatal error in Upgrade DB to 4.2.alpha1: Contributions
+            // davej 26 Nov 2013
             $lineParams['price_field_id'] =
-              CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $result->price_set_id, 'id', 'price_set_id');
+              #CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $result->price_set_id, 'id', 'price_set_id');
+              CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $priceSetId, 'id', 'price_set_id');
             $lineParams['label'] = 'Contribution Amount';
           }
           $lineParams['qty'] = 1;

- After seeing the fix for CRM-12273 at line 642.

Does this seem correct?

Dave J

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Fatal error on Upgrade DB to 4.2.alpha1: Contributions - price_set_id NULL
November 26, 2013, 05:50:25 am
Quote
- After seeing the fix for CRM-12273 at line 642.

This issue was fixed for 4.3, can you try upgrading 4.1.6  to 4.3.x or 4.4.2

Kurund
Found this reply helpful? Support CiviCRM

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: Fatal error on Upgrade DB to 4.2.alpha1: Contributions - price_set_id NULL
November 26, 2013, 06:10:04 am
Hi Kurund,

Thanks for the quick reply. 4.2.14 FourTwo.php has fixes for CRM-12273:

Line 449:
Code: [Select]
    elseif (!CRM_Utils_Array::value('otherAmount', $options) && !CRM_Utils_Array::value('membership', $options)) {
      //CRM-12273
      //if options group, otherAmount, membersip is empty then return, contribution should be default price set
      return;
    }

Line 642:
Code: [Select]
        //CRM-12273
        //check if price_set_id is exist, if not use the default contribution amount
        if (isset($result->price_set_id)){
          $priceSetId = $result->price_set_id;
        }
        else{
          $defaultPriceSets = CRM_Price_BAO_Set::getDefaultPriceSet();
          foreach ($defaultPriceSets as $key => $pSet) {
            if ($pSet['name'] == 'contribution_amount'){
              $priceSetId = $pSet['setID'];
            }
          }
        }

        $params = array(
          '1' => array($priceSetId, 'Integer'),
          '2' => array($result->total_amount, 'String'),
        );

Line 672:
Code: [Select]
       else {
          $params = array(
            'price_set_id' => $priceSetId,
            'name' => 'other_amount',
          );

However looking at this commit for CRM-12273:
https://github.com/civicrm/civicrm-core/commit/e22815ce923c09f88a0efd4b2a94a68a78265311
the last change in that diff has NOT been applied to 4.2.14: 4.2.14 has this at line 685:

          else {
            $lineParams['price_field_id'] =
              CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $result->price_set_id, 'id', 'price_set_id');
            $lineParams['label'] = 'Contribution Amount';
          }

Maybe backporting the fix from 4.3 to 4.2 failed because in 4.3 this line has changed from CRM_Price_DAO_Field to CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field ? My fix changes $result->price_set_id to $priceSetId in this line. Is that the correct fix for 4.2?

Cheers,

Dave

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: Fatal error on Upgrade DB to 4.2.alpha1: Contributions - price_set_id NULL
November 26, 2013, 06:13:17 am

hey davej:

might want to move this discussion to the LTS board and/or do a quick post out there linking to this forum since the LTS group monitors that board

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

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: Fatal error on Upgrade DB to 4.2.alpha1: Contributions - price_set_id NULL
November 26, 2013, 07:17:58 am
Thanks, Lobo, I've posted this in LTS:

http://forum.civicrm.org/index.php/topic,30839.0.html

Cheers,

Dave

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Fatal error on Upgrade DB to 4.2.alpha1: Contributions - price_set_id NULL

This forum was archived on 2017-11-26.