When using the Commerce module in phpunit testing of other modules, at core 10.2 we get a deprecation error
Using a translatable string as a category for field type is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3364271
The change record is actually https://www.drupal.org/node/3375748
(not https://www.drupal.org/node/3364271 as in the message, which gives a 404)
My module did not have the field definitions so I tracked it down to Commerce (and also Address and Plugin)
The problem line looks to be src/Plugin/Field/FieldType/PluginItem.php#L17
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3413020.patch | 690 bytes | sidharth_soman |
Issue fork commerce-3413020
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
sidharth_soman commentedHere's a patch for it
Comment #3
jsacksick commentedWell I think we need Commerce to define a field type category, as indicated in the change record.
We need a
commerce.field_type_categories.ymland we might as well define an icon etc.Comment #4
jonathan1055 commentedThere is no branch test at 10.2 to compare against, but I don't think there is test coverage for all of these. A quick grep of the source shows there are six more places that need to be fixed:
@sidharth_soman I am not working on these changes, so you are welcome to add these to your patch. It would be useful to have a branch test of 3.0.x at 10.2 to see if there are any deprecation warnings. You may want to prove that first.
Then add the commerce.field_type_categories.yml afterwards, so that the UI has the translation available.
Comment #5
jsacksick commented@jonathan1055: Gitlab CI I think uses D10.2 (probably even the dev 10 version).
Comment #6
jonathan1055 commentedAh yes thanks, gitlab pipelines have just recently been updated to run against 10.2
I can see on https://git.drupalcode.org/project/commerce/-/pipelines/72224/test_report there are some Ajax failures which the 10.1 pipeline did not have, but there are no deprecation warnings. This could be becuase (a) the Gitlab template is not configured to show them or fail for them, or (b) the code that would create the warnings is not covered by the tests. From a standing start, I would have said (a) is the likely reason, because you do have a huge amount of test coverage here. But the patch from #2 did not have the deprecation warnings for the six additional places that need fixing.
I know that the deprecation errors do show on drupal.org testing, so here's a patch which does not make that change, to see what drupal.org shows.
Comment #8
czigor commentedComment #15
jsacksick commentedMerged, thanks!
Comment #16
jsacksick commented