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 »
  • 2.1 Release Testing »
  • CiviPledge fails on Joomla online contribution page
Pages: [1]

Author Topic: CiviPledge fails on Joomla online contribution page  (Read 6360 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
CiviPledge fails on Joomla online contribution page
September 28, 2008, 04:39:11 pm
When I try to make a contribution with the pledge option set, I get the following error after pressing the Make contribution button ...

Quote
Sorry. A non-recoverable error has occurred.

is not of the type Integer

Return to home page.

Unable to reproduce on the Joomla demo site, as the contribute page is broken. Has anyone else had this problem?

Thanks,
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: CiviPledge fails on Joomla online contribution page
September 28, 2008, 05:56:53 pm
can you reproduce on the drupal demo? i'll get the joomla demo workign later tonite.

Update: realized joomla demo was still stuck on 2.0, we will upgrade to 1.5 and 2.1 this week

lobo
« Last Edit: September 28, 2008, 06:05:01 pm by Donald 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: CiviPledge fails on Joomla online contribution page
September 28, 2008, 10:10:03 pm
Drupal demo

I tried but I've forgotten how to do a test payment with PayPal (I got an error). Could you remind me?

More information

BTW, I'm using 2.1 beta 6 on Joomla! 1.5. This is the backtrace ...

Quote
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php, backtrace, 260
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Utils/Type.php, fatal, 260
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php, validate, 906
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php, composeQuery, 859
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Pledge/BAO/Payment.php, executeQuery, 300
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Pledge/BAO/Payment.php, updatePledgePaymentStatus, 171
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Pledge/BAO/Pledge.php, create, 212
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php, create, 726
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Contribute/BAO/Contribution/Utils.php, processContribution, 194
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php, processConfirm, 465
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Core/Form.php, postProcess, 247
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Core/StateMachine.php, mainProcess, 166
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php, perform, 63
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Core/Controller.php, handle, 232
/var/www/cbfj15/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php, run, 197
/var/www/cbfj15/administrator/components/com_civicrm/admin.civicrm.php, invoke, 45
/var/www/cbfj15/administrator/components/com_civicrm/admin.civicrm.php, civicrm_invoke, 22
/var/www/cbfj15/libraries/joomla/application/component/helper.php, require_once, 162
/var/www/cbfj15/administrator/includes/application.php, renderComponent, 130
/var/www/cbfj15/administrator/index.php, dispatch, 67
/var/www/cbfj15/administrator/index2.php, include, 14

The complaint occurs when the code is trying to update the status of the pledge. The two integer arguments that are being passed into executeQuery are the Pledge-Id and the Status-Id, and one of these is either NULL or the empty string.

In my database, pledges created through the contact screen have the civicrm_pledge.status_id set to '2', which is the contribution_status value for 'Pending'. For those created from the online contribution page, this same value is '0', which doesn't correspond to a contribution_status value.

Ken

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: CiviPledge fails on Joomla online contribution page
September 28, 2008, 10:13:02 pm
Ken:

Have you done fresh CiviCRM v2.1 install or upgrade ?

Also can you give exact steps to replicate this issue.

Kurund
Found this reply helpful? Support CiviCRM

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: CiviPledge fails on Joomla online contribution page
September 29, 2008, 06:57:29 am
Kurund,

I am using CiviCRM 2.1 beta 6. I experience the fault when making a pledge from an online contribution page (always) but not when making a pledge from the Contact screen.

But I think I've found the issue, plus two other secondary issues ...

1. Calls to CRM_Contribute_PseudoConstant::contributionStatus are incorrect
2. The logic of CRM_Contribute_PseudoConstant::contributionStatus fails to cache the array of values, and assumes there is an 'Overdue' status in the database
3. There are unnecessary calls to CRM_Contribute_PseudoConstant::contributionStatus in CRM_Pledge_BAO_Payment::create

Calls to contributionStatus are incorrect

The problem I'm experiencing occurs at the following point in CRM/Pledge/BAO/Payment.php ...

Code: [Select]
313     static function calculatePledgeStatus( $pledgeId )
314     {
315         require_once 'CRM/Contribute/PseudoConstant.php';
316         $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus( );
...         
328         if ( array_search( 'Overdue', $allStatus ) ) {
329             $statusId = array_search( 'Overdue', $paymentStatusTypes );
330         } else if ( array_search( 'Completed', $allStatus ) ) {
331             if ( count( array_count_values( $allStatus) ) == 1 ) {
332                 $statusId = array_search( 'Completed', $paymentStatusTypes );
333             } else {
334                 $statusId = array_search( 'In Progress', $paymentStatusTypes );
335             }
336         } else {
337             $statusId = array_search( 'Pending', $paymentStatusTypes );
338         }

The contributionStatus function is called at line 316 with the argument $all set to its default value 'false'. This means that the values for the statuses 'In Progress' and 'Overdue' are excluded from $paymentStatusTypes.

However at line 334, the value 'In Progress' is searched for, and $statusId is set to the non-numeric value 'false' rather than the expected value '5'. This results in the observed failure. It also explains why pledges work when created from the Contact screen - none of the payments have completed, so the test at line 330 fails, and the faulty logic is not exercised.

I suspect that contributionStatus should be called here with the argument 'true'.

I've seen something similar in CRM/Pledge/BAO/Pledge.php ...

Code: [Select]
166        //get All Payments status types.
167        require_once 'CRM/Contribute/PseudoConstant.php';
168        $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus( );
169       
170        //update the pledge status only if it does NOT come from form
171        if ( ! isset ( $params['pledge_status_id'] ) ) {
172            if ( isset ( $params['contribution_id'] ) ) {
173                if ( $params['installments'] > 1 ) {
174                    $params['status_id'] = array_search( 'In Progress', $paymentStatusTypes );
175                }
176            } else {
177                $params['status_id'] = array_search( 'Pending', $paymentStatusTypes );
178            }
179        }

On line 168 the $all argument to contributionStatus is omitted, so it defaults to 'false'. However, on line 174, the 'In Progress' status is searched for. Thus $params['status_id'] will be set to 'false' rather than a number. I suspect this in turn will lead to problems when the first issue is fixed.

I suggest that all calls to CRM_Contribute_PseudoConstant::contributionStatus should be inspected to check whether the $all argument should be supplied with the value 'true'.

The logic of contributionStatus fails to cache the array, and assumes there is an 'Overdue' status in the database

The code for CRM_Contribute_PseudoConstant::contributionStatus seems to be written to cache the array of statuses, but fails to do so.

Code: [Select]
    public static function &contributionStatus( $all = false )
    {
        self::$contributionStatus = array();
        if ( ! self::$contributionStatus ) {
            require_once "CRM/Core/OptionGroup.php";
            self::$contributionStatus = CRM_Core_OptionGroup::values("contribution_status");
            // Remove status values that are only used for recurring contributions or pledges (In Progress, Overdue).
            if( $all == false ) {
                unset( self::$contributionStatus['5']);
                unset( self::$contributionStatus['6']);
            }
        }
        return self::$contributionStatus;
    }

It seems that each time the function is called, the array is emptied and then repopulated. Can I suggest that this function is rewritten to produce two arrays (one with all the statuses and the other with not all) on the first invocation, and then to return the appropriate one depending on the value of $all.

Also, my database doesn't contain a 'contribution_status' of 'Overdue'. Is this a logic error in this function or a data conversion issue?

A much better solution would be to treat the pledge statuses as a separate set from those for contributions. Trying to reuse them is causing problems, particularly as pledges and contributions have semantic overlap.

Too many calls to contributionStatus

In CRM_Pledge_BAO_Payment::create there are calls to CRM_Contribute_PseudoConstant::contributionStatus on lines 127 and 129, and (in a loop) on lines 136 and 138. One call would suffice.

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: CiviPledge fails on Joomla online contribution page
September 29, 2008, 07:45:53 am

can u please file an issue for this. I'm taking a look and will review and cleanup the code before the next release

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

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: CiviPledge fails on Joomla online contribution page
September 30, 2008, 05:11:59 am
For tracking purpose: http://issues.civicrm.org/jira/browse/CRM-3642

Kurund
Found this reply helpful? Support CiviCRM

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: CiviPledge fails on Joomla online contribution page
September 30, 2008, 04:02:49 pm
Ken - thx for catching this! Issue has been resolved and fix will be included in next distribution or you can get changes at:

http://fisheye.civicrm.org/browse/CiviCRM-2-1/CRM/Contribute/PseudoConstant.php?r1=17304&r2=17324
Protect your investment in CiviCRM by  becoming a Member!

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: CiviPledge fails on Joomla online contribution page
September 30, 2008, 05:50:18 pm
Guys,

Thanks for all your hard work. I've looked at the changes David mentions and I just have a couple of questions ...

  • On line 328 of CRM/Pledge/BAO/Payment.php a search is made for the value 'Overdue'. Will a 'contribution_status' with value 6 and label 'Overdue' be added to the data conversion script for 2.1?
  • Is there a possibility of a regression issue with other uses of 'contribution_status' that don't expect the value 'Overdue' (eg, a user selects 'Overdue' in a drop-down list of contibution statuses, but the code doesn't handle this case)

I'm apologising in advance because I'll be away for a week and I will be off-line (my wife seems to think 'holiday' implies 'no Internet' - what can she be thinking?). So I'll be unable to test this until I get back.

Keep plugging away at it guys ... looking forward to 2.1 ... and especially to pledges!
Ken

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: CiviPledge fails on Joomla online contribution page
October 01, 2008, 10:44:01 am
The additional statuses are inserted during upgrade process.

Assigning a "pledge-specific" status to a contribution doesn't seem to have any significant side effects - but should be blocked at some point. Issue for 2.2 added:
http://issues.civicrm.org/jira/browse/CRM-3651

(have a good holiday) :-)
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 2.1 Release Testing »
  • CiviPledge fails on Joomla online contribution page

This forum was archived on 2017-11-26.