Hello Guys, i've this error when using PagosOnline for Ubercart:

Notice: Undefined variable: null in uc_payment_method_settings_form() (line 109 of C:\xampp\htdocs\tienda_demo_ubercart_d7\sites\all\modules\ubercart\payment\uc_payment\uc_payment.admin.inc).

This was my Step by Step:

  1. Installing Ubercart
  2. Installing PagosOnline
  3. I'd open mysite.com/admin/store/settings/payment
  4. I'd check Ubercart as payment method and saving
  5. I'd open PagosOnline Settings at mysite.com/admin/store/settings/payment/method/pagosonline

What can it be?
Thanks for your help!

Comments

DanZ’s picture

Status: Active » Closed (duplicate)

This looks like an error in the code that generates the config form for PagosOnline.

You have already reported this in the PagosOnline queue at #1991586: Undefined variable: null en uc_payment_method_settings_form() línea 109 de uc_payment.admin.inc, which is the right thing to do.

This is not an Ubercart problem. You may wish to install the Devel module and examine a Krumos backtrace to troubleshoot this more.

DanZ’s picture

Status: Closed (duplicate) » Active

On a closer look, I've decided that I'm wrong. This is an Ubercart bug.

/**
 * Displays settings for a single payment method.
 */
function uc_payment_method_settings_form($form, &$form_state, $method_id) {
  $callback = _uc_payment_method_data($method_id, 'callback');
  $form = $callback('settings', $null, array(), $form_state);  // <----  Line 109
  return system_settings_form($form);
}

Note the variable $null. It's not initialized. This function could never work right. I don't know why it didn't blow up for lots of other payment methods.

Maybe it has something to do with this: Elsewhere in the file, there is the following function:

function uc_payment_methods_form($form, &$form_state) {
    // ...skip lots of lines...
    $null = NULL;
    $method_settings = $method['callback']('settings', $null, array(), $form_state);
    // ....
}

I don't understand the point of assigning NULL to a variable, instead of just using NULL.... Try changing that $null to NULL and see if that helps.

dvasquez’s picture

Status: Active » Needs review

It´s working for me!
Thanks man!

DanZ’s picture

Status: Needs review » Active

No patch to review, yet.

longwave’s picture

Fixed in http://drupalcode.org/project/ubercart.git/commitdiff/fa7e8d0

$null = NULL; is necessary here because the second parameter of the payment method callback is expected to be a reference by some payment methods. Passing a plain NULL here results in an error when using the settings link on several other payment methods such as PayPal. That doesn't explain why the undefined variable doesn't show when using other core-provided payment methods (can you pass undeclared variables by reference in PHP?!), but the committed fix should work for all cases.

longwave’s picture

Status: Active » Fixed
dvasquez’s picture

Status: Fixed » Active

@longwave, you're right about that. I think the best way is re-declarate the variable into uc_payment_method_settings_form function, some like this:

/**
 * Displays settings for a single payment method.
 */
function uc_payment_method_settings_form($form, &$form_state, $method_id) {
  $null = NULL; // <-- adding this var; new line 108
  $callback = _uc_payment_method_data($method_id, 'callback');
  $form = $callback('settings', $null, array(), $form_state);
  return system_settings_form($form);
}

It works for me...

tr’s picture

tr’s picture

Version: 7.x-3.4 » 7.x-3.x-dev
Status: Active » Fixed
DanZ’s picture

dvasquez’s picture

@DanZ, i see... Well, it's working with COD, PagosOnline, 2Checkout, Google Checkout, Check, PayPal Express Checkout, PayPal Website Payments Standard.

No error, Good Work!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.