• Resolved le roux

    (@le-roux)


    I am getting this error when I click submit and confirm button

    Fatal error: Call to a member function cancel() on a non-object in /public_html/www.mysite.com/wp-content/plugins/paid-memberships-pro/preheaders/checkout.php on line 981

    The user is created successfully in my wordpress database but I get that error message on my webpage

    http://wordpress.org/extend/plugins/paid-memberships-pro/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter le roux

    (@le-roux)

    Hi. I upgraded to version 1.7.0.3. but I still have the same problem.

    Hi

    I have the same problem.

    Tried different versions of the plugin and the suggested fixes

    Please advise

    Hitesh

    Plugin Author Jason Coleman

    (@strangerstudios)

    Try 1.7.0.4, which is going out now.

    Just checking back @le roux @leadingtowin to see if the update resolved this for you.

    Hello – I have the same problem with the last several versions. It only applies to a free signup. Any solution for this bug? I am on 1.7.0.4 now by the way.

    I cleared the fatal error by changing line 981 of preheaters/checkout.php to this:

    if(isset($morder) && $morder->cancel())

    which allows the following error to be displayed:

    “IMPORTANT: Something went wrong during membership creation. Your credit card was charged, but we couldn’t assign your membership. You should not submit this form again. Please contact the site owner to fix this issue.”

    Which of course makes no sense because the issue is only exposed on a free signup. There’s clearly some problem with the logic in processing a free order, I suspect somewhere where pmpro_isLevelFree() is called.

    I have isolated the probplem to a mySQL error associated with this code starting around line 565 of functions.php:

    $sql = "INSERT INTO $wpdb->pmpro_memberships_users (user_id, membership_id, code_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, trial_amount, trial_limit, startdate, enddate)
    						VALUES('" . $level['user_id'] . "',
    						'" . $level['membership_id'] . "',
    						'" . intval($level['code_id']) . "',
    						'" . $level['initial_payment'] . "',
    						'" . $level['billing_amount'] . "',
    						'" . $level['cycle_number'] . "',
    						'" . $level['cycle_period'] . "',
    						'" . $level['billing_limit'] . "',
    						'" . $level['trial_amount'] . "',
    						'" . $level['trial_limit'] . "',
    						" . $level['startdate'] . ",
    						" . $level['enddate'] . ")";
    
    				if(!$wpdb->query($sql))
    				{
    					$pmpro_error = __("Error interacting with database", "pmpro") . ": ".(mysql_errno()?mysql_error():'unavailable');
    					return false;
    				}

    I have not yet been able to figure it out but perhaps it is a malformed SQL statement? Here it as final output:

    INSERT INTO wp_pmpro_memberships_users (user_id, membership_id, code_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, trial_amount, trial_limit, startdate, enddate) VALUES('1', '1', '0', '0.00', '0.00', '0', '', '0', '0.00', '0', NOW(), NULL)

    Ok I’m getting somewhere: I turned on error reporting and here’s what i got back:

    WordPress database error: [Data truncated for column 'cycle_period' at row 1]
    INSERT INTO wp_pmpro_memberships_users (user_id, membership_id, code_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, trial_amount, trial_limit, startdate, enddate) VALUES('1', '1', '0', '0.00', '0.00', '0', '', '0', '0.00', '0', NOW(), NULL)

    As it turns out, my instance of mySQL server is in Strict mode as explained here and expects the insertion of data for the cycle_period to be an enum value. Although there is a default value for this field set in the table of “Month”, when it receives an empty value it throws the error. A quick work around for me was to add “INSERT IGNORE INTO” to the above SQL statement but that seems to be an invitation for some other problems. Perhaps some code needs to be added to force feed an enum value for cycle_period even if it does not apply? This might make the plugin more tolerant of a STRICT MODE mySQL environment. Also, I suggest the addition of $wpdb->show_errors(); somewhere in the script.

    Ok … I just couldn’t leave this one alone! Here’s a possible permanent solution. Just add this line directly above “$sql = “INSERT INTO $wpdb->pmpro_memberships_us…” around line 565 of functions.php:

    if ($level['cycle_period'] == '') $level['cycle_period'] = 0;

    Per the mySQL reference manual here an index number of 0 can be passed on the insert, which will be allowed in a STRICT MODE setup without throwing an error. An examination of the resulting inserted row reveals an empty value for cycle_period, I believe as intended on a free level, right?.

    PMPRO developers, please let me know your thoughts. Thanks much.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Fatal error after clicking submit button’ is closed to new replies.