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.
To reproduce:
- Create a order.
- On Admin page, go Store -> orders
- Select a order.
- Click the tab "Payment"
- Select a payment.
Not sure if its necessary to install another module to reproduce this error.
So, the thing is, its necessary to cast the from string to numeric when a calculation is happen:
"1000" to 1000
"1.3" to 1.3
... and so on. Not sure if its a custom page in this project, but I'm attaching the screenshot of the page.
Comment | File | Size | Author |
---|---|---|---|
#6 | 3035138-6.default-amount.patch | 766 bytes | rszrama |
| |||
#3 | php72-warning-commerce-currency-amount-to-decimal-3035138-3.patch | 399 bytes | jkamizato |
#2 | Screenshot from 2019-02-22 15-21-08.png | 24.78 KB | jkamizato |
Comments
Comment #2
jkamizato CreditAttribution: jkamizato as a volunteer and at Promet Source commentedComment #3
jkamizato CreditAttribution: jkamizato as a volunteer and at Promet Source commentedHere my solution.
Comment #4
mrP CreditAttribution: mrP commentedRan across the same warning on multiple sites. Patch #3 applies cleanly to latest dev code and no more warnings.
Comment #5
kscheirerbased on #4
Comment #6
rszrama CreditAttribution: rszrama at Centarro commentedConfirmed the bug, but rather than cast $amount to a float in the return, I'm going to edit the transaction add form to use a numeric value as specified instead of an empty string. I suppose we just always depended on '' being cast to 0 in numeric operations in the past when there's really no reason not to pass 0 to begin with.
Comment #8
rszrama CreditAttribution: rszrama at Centarro commentedCommitted.
Comment #10
solideogloria CreditAttribution: solideogloria commentedRelated: #2927409: Avoid calling commerce_currency_amount_to_decimal() with an empty string $amount