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.
This serves as a tracking and patch testing issue for porting D7 Ubercart Rules Conditions to D8. I am also using this to document the process, because currently Rules has very little documentation for D8 and no information about porting between the two very different major versions.
These are the steps in the process:
Tasks
- Make a list of conditions that Ubercart defines. Publish that here!
- Ubercart conditions are defined by
hook_rules_condition_info()
, which may be found in<modulename>/<modulename>.rules.inc
. Refer to the D7 version of these files to ensure that you port ALL the conditions that were in D7 Ubercart. - Write a
<modulename>/src/Plugin/Condition/<conditionname>.php
class for each condition that the module defines. Use the classes provided by the Rules module inrules/src/Plugin/Condition/
as examples. - Manually test, in the Rules UI, that each condition shows up and has the same arguments as it did in D7.
- Manually review the conditions plugins to make sure all comments and text strings are correct for each condition.
- Manually test, by creating test reaction rules in the Rules UI, that each condition works as expected.
- Write unit test cases for each condition. Use the code in
rules/tests/src/Unit/Integration/Condition/*
as examples.
Remaining tasks
Tasks 1-4 have been performed. Task 3 REQUIRES fixes to core Rules - there is a patch in #2664280-24: Select lists in action & condition configuration forms that works for this. Help with tasks 5-7 is still needed.
- Manually review the conditions plugins to make sure all comments and text strings are correct for each condition.
- Manually test, by creating test reaction rules in the Rules UI, that each condition works as expected.
- Write unit test cases for each condition. Use the code in
rules/tests/src/Unit/Integration/Condition/*
as examples.
Comment | File | Size | Author |
---|---|---|---|
#23 | 2924151-23.patch | 16.7 KB | TR |
| |||
#19 | 2924151-19.patch | 12.47 KB | TR |
| |||
#18 | 2924151-18.patch | 11.71 KB | TR |
| |||
#14 | 2924151-14-rules-conditions.patch | 43.62 KB | TR |
#11 | 2924151-9-rules-conditions.patch | 43.66 KB | TR |
Comments
Comment #2
TR CreditAttribution: TR commentedHere is a list of Rules Conditions provided by Ubercart in Drupal 7:
Node
Order
Order: Product
Payment
Order: Shipping Quote
Comment #3
TR CreditAttribution: TR commentedComment #4
TR CreditAttribution: TR commentedAdded related issues.
Comment #5
TR CreditAttribution: TR commentedHere is my first pass at porting all the Rules conditions. I think they work, but it's going to take a second set of eyes to be sure since we don't have any tests yet. I just counted and apparently I didn't port one of the conditions yet (uc_quote_condition_order_shipping_method). I will add that to the patch later.
Remember, to try this you will need to enable the latest -dev of Rules and also apply the patch from #2664280-24: Select lists in action & condition configuration forms.
I expect one failure from the testbot, since we still have that core 8.5.x regression. Should pass on 8.4.x.
Comment #7
TR CreditAttribution: TR commentedFixed the coding standards problems and added the missing condition that I mentioned in #5.
Comment #9
TR CreditAttribution: TR commentedHmm, looks like random test failures in the 8.5.x branch. 8.4.x passed. Let's correct some coding standards and run it again ... Want to get it down to just the 1 uc_tax failure in 8.5.x.
Comment #11
TR CreditAttribution: TR commentedComment #13
TR CreditAttribution: TR commented1 fail on 8.5.x, 0 fails on 8.4.x, as expected.
Comment #14
TR CreditAttribution: TR commentedMinor fixes.
Comment #15
TR CreditAttribution: TR commentedCommitted #14.
Remember, these still require the patch to Rules from #2664280-24: Select lists in action & condition configuration forms.
The following conditions still cause problems with task #6:
Comment #17
TR CreditAttribution: TR commentedComment #18
TR CreditAttribution: TR commentedAdding the missing uc_payment_condition_order_balance condition and cleaning up some others.
Comment #19
TR CreditAttribution: TR commentedAnd one more small change to node_is_product.
Comment #22
TR CreditAttribution: TR commentedComment #23
TR CreditAttribution: TR commentedI think this should take care of the remaining problems mentioned in #15.
Comment #25
TR CreditAttribution: TR commentedCommitted.
Comment #26
TR CreditAttribution: TR commentedComment #27
TR CreditAttribution: TR commented