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

CommentFileSizeAuthor
#6 3413020-6.patch732 bytesjonathan1055
#2 3413020.patch690 bytessidharth_soman

Issue fork commerce-3413020

Command icon 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

jonathan1055 created an issue. See original summary.

sidharth_soman’s picture

StatusFileSize
new690 bytes

Here's a patch for it

jsacksick’s picture

Well I think we need Commerce to define a field type category, as indicated in the change record.
We need a commerce.field_type_categories.yml and we might as well define an icon etc.

jonathan1055’s picture

There 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:

./modules/order/src/Plugin/Field/FieldType/AdjustmentItem.php:
  *   category = @Translation("Commerce"),
./modules/tax/src/Plugin/Field/FieldType/TaxNumberItem.php: 
  *   category = @Translation("Commerce"),
./modules/checkout/src/Plugin/Block/CheckoutProgressBlock.php:
  *   category = @Translation("Commerce")
./modules/price/src/Plugin/Field/FieldType/PriceItem.php:
  *   category = @Translation("Commerce"),
./modules/cart/src/Plugin/Block/CartBlock.php: 
  *   category = @Translation("Commerce")
./src/Plugin/Field/FieldType/RemoteIdItem.php: 
  *   category = @Translation("Commerce"),

@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.

jsacksick’s picture

@jonathan1055: Gitlab CI I think uses D10.2 (probably even the dev 10 version).

jonathan1055’s picture

StatusFileSize
new732 bytes

Ah 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.

czigor made their first commit to this issue’s fork.

czigor’s picture

Version: 3.0.x-dev » 8.x-2.x-dev
Status: Active » Needs review

czigor changed the visibility of the branch 3413020-using-a-translatable to hidden.

  • jsacksick committed f68cffb6 on 8.x-2.x authored by czigor
    Issue #3413020 by czigor: Using a translatable string as a category for...

  • jsacksick committed 094515a9 on 3.0.x authored by czigor
    Issue #3413020 by czigor: Using a translatable string as a category for...
jsacksick’s picture

Status: Needs review » Fixed

Merged, thanks!

jsacksick’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.