In my watchdog report I'm getting this php notice:

Warning: Illegal string offset 'title' in commerce_payment_method_get_title() (line 617 of /home/username/public_html/sites/all/modules/contrib/commerce/modules/payment/commerce_payment.module).

I am using PHP version 5.4

CommentFileSizeAuthor
#2 illegal_titles-2341617-2.patch613 bytesDeciphered
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

Category: Bug report » Support request
Status: Active » Closed (works as designed)

It sounds to me like you have some payment method module on your site that didn't define the required 'title' value in its info array. I'd start looking there. It's possible that something else has altered that value away, but that would be unusual.

Deciphered’s picture

Version: 7.x-1.10 » 7.x-1.x-dev
Status: Closed (works as designed) » Needs review
FileSize
613 bytes

I get this message, not because it hasn't defined the required 'title' value, but rather because the function commerce_payment_method_get_title() is getting invoked a second time (for whatever reason) and the second time when it calls commerce_payment_methods() it receives the each payment methods title string instead of full array.

This appears to be caused by the array returned from commerce_payment_methods() being passed by reference, and therefore any changes made directly to it (as is exactly what commerce_payment_method_get_title() does) is stored statically and returned next time around.

Simple fix, don't manipulate $payment_methods, instead append the relevant values to another array to be returned from the function.

Patch attached.

joelpittet’s picture

Category: Support request » Bug report
Status: Needs review » Reviewed & tested by the community

This patch seems very good because it avoids overwriting the existing array to build up the titles.

adamwhite’s picture

This patch works for me.

I encountered this issue by having a rule that has two "Select payment method comparison" conditions in it separated by an OR (to check if the payment method was A or B). Once the second condition was added I started seeing the error.

joelpittet’s picture

Issue tags: +commerce-sprint
rszrama’s picture

Status: Reviewed & tested by the community » Fixed

Committed with a comment fix.

rszrama’s picture

Derp. Committed now.

  • rszrama committed 4a9e25a on 7.x-1.x authored by Deciphered
    Issue #2341617 by Deciphered, rszrama: Illegal string offset 'title' in...

Status: Fixed » Closed (fixed)

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