ISSUE SUMMARY
Using the "Set Data Value" action in Rules to set the created property on a commerce line item entity fails with this fatal error:
TO REPRO
Here is the simplest rule component that reproduces this error:
{ "rules_line_item_argumentcounterror" : {
"LABEL" : "REPRODUCE Line-Item fatal ArgumentCountError",
"PLUGIN" : "action set",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : {
"line_item" : { "label" : "Line Item", "type" : "commerce_line_item" },
"new_date" : { "label" : "New Date", "type" : "date" }
},
"ACTION SET" : [
{ "data_set" : { "data" : [ "line-item:created" ], "value" : [ "new-date" ] } }
]
}
}
Steps to reproduce:
- Import this rule component.
- Locate an existing line item ID to use as a test subject. Any line item type/bundle should reproduce this error.
- Execute this rule.
- Enter your test line item ID as the "Line Item" argument.
- Either accept the default date (now) or enter your preferred date for the "New Date" argument. Any valid date should reproduce this error.
- Press Execute.
NOTE
We have a rule in occasional but regular use, and never saw this until after we upgraded to PHP 7.1.
I would tag it PHP71 except now I lack a pre-PHP7 test environment I cannot be sure that is the definitive factor.
Code inspection strongly suggests that this might have been something that PHP 5.6 tolerated, but PHP 7.1's strictness now forbids.
Comment | File | Size | Author |
---|---|---|---|
#3 | line-item-argumentcounterror-3021095-3.patch | 643 bytes | josephr5000 |
ArgumentCountError.png | 77.18 KB | josephr5000 |
Comments
Comment #2
josephr5000 CreditAttribution: josephr5000 for Cascade Bicycle Club commentedComment #3
josephr5000 CreditAttribution: josephr5000 for Cascade Bicycle Club commentedHere's a patch to fix this. Changing status to NEEDS REVIEW.
NOTE ABOUT PRIORITY: I set priority to MAJOR because this gives users a "The site has encountered an unexpected error." which is basically a hard crash. I don't think it is CRITICAL since you can avoid this by not running rules that set commerce-line-item:created, and I haven't yet found any built-in rules in Commerce that run this action. But the action is available and legitimate to use, should work reliably, and should definitely not crash the page.
Comment #4
phdhiren CreditAttribution: phdhiren as a volunteer and at Intelliswift commentedIs there any update on the issue, when the patch will be merged?
Comment #5
josephr5000 CreditAttribution: josephr5000 for Cascade Bicycle Club commented@phdhiren: I doubt this will be merged while status remains at NEEDS REVIEW. It needs others to actually try the patch and report their test results. Have you tried it? What success (or lack thereof) did you experience?
Comment #6
rszrama CreditAttribution: rszrama at Centarro commented@josephr5000 I have a ddev env't for testing in different PHP versions. I was able to reproduce the issue easily using the component you provided, which made testing the patch super simple. This works great - thanks for your work those many years ago!