Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#2 | illegal_titles-2341617-2.patch | 613 bytes | Deciphered |
Comments
Comment #1
rszrama CreditAttribution: rszrama commentedIt 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.
Comment #2
Deciphered CreditAttribution: Deciphered commentedI 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 callscommerce_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 whatcommerce_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.
Comment #3
joelpittetThis patch seems very good because it avoids overwriting the existing array to build up the titles.
Comment #4
adamwhite CreditAttribution: adamwhite at JMR Logics commentedThis 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.
Comment #5
joelpittetComment #6
rszrama CreditAttribution: rszrama at Centarro commentedCommitted with a comment fix.
Comment #7
rszrama CreditAttribution: rszrama at Centarro commentedDerp. Committed now.