1) Would be good to sort payment method options in payment_form_process_method().
2) Better to use natcasesort() in payment_method_options() as well.
3) fixed a typo

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Xano’s picture

Status: Needs review » Fixed

Дуже дякую!

  • Xano committed 79624e7 on 7.x-1.x authored by a.milkovsky
    Issue #2491251 by a.milkovsky: Sort payment methods
    

Status: Fixed » Closed (fixed)

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

amandahart’s picture

I am running into an issue that I believe is related to this patch, so I wanted to bump this up to get some attention.

I've installed Payment 7.x-1.15 on a fresh Drupal 7.38 install to test for a possible client event registration/payment system, and am receiving this warning message when I view admin/content/payment:

Warning: natcasesort() expects parameter 1 to be array, null given in payment_method_options() (line 1157 of ~/git/drupal-empty-testing/docroot/sites/all/modules/payment/payment.ui.inc).

Checking the code, it seems that line 1157 in the function payment_method_options() is using $pmid_options as a parameter, but that variable is completely uninitialized within the scope of the function. I suspect it is intended to be $options (or $options needs to be renamed to $pmid_options). I've pasted the current code below so you can see at a glance what I am referring to:

/**
 * Return payment methods for use in form elements.
 *
 * @return array
 *   Keys are payment method IDs. Values are payment method specific titles.
 */
function payment_method_options() {
  $options = array();
  foreach (entity_load('payment_method') as $payment_method) {
    $options[$payment_method->pmid] = check_plain($payment_method->title_specific);
  }
  natcasesort($pmid_options);

  return $options;
}

(This is my first post on the Drupal site, so please forgive any formatting errors... thank you!)

Xano’s picture

Status: Closed (fixed) » Active
a.milkovsky’s picture

Status: Active » Needs review
FileSize
411 bytes

whoops. please review
amandahart, thanks for reporting!

amandahart’s picture

I just ran the patch on my local machine and the warning has disappeared. The change looks correct to me. Thanks for fixing it! Looking forward to the next release.

a.milkovsky’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, so changing the status. I would credit it to amandahart

Xano’s picture

Status: Reviewed & tested by the community » Fixed

@amandahart: Welcome here, and thanks for reporting the problem and proposing the solution. I have credited you in the commit for your work. If you'd like to write patches yourself in the future, I can recommend these excellent handbook pages.

@a.milkovsky: thanks for the review, and giving credit!

  • Xano committed bcb6ec9 on 7.x-1.x authored by amandahart
    Issue #2491251 by a.milkovsky, amandahart: Sort payment methods
    

Status: Fixed » Closed (fixed)

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

guardian87’s picture

Patch worked perfectly here as well!