Removed getCurrentUserId have not been removed from base_field_override.

Created on 19 June 2020, almost 5 years ago
Updated 6 March 2024, about 1 year ago

Problem/Motivation

If uid field on product or product_variation is overriden (e.g. core.base_field_override.commerce_product_variation.default.uid.yml) long time ago it could contain:

default_value_callback: 'Drupal\commerce_product\Entity\ProductVariation::getCurrentUserId'

But getCurrentUserId is deprecated now and removed in current Commerce, so on entity form it prints:

Warning: call_user_func() expects parameter 1 to be a valid callback, class 'Drupal\commerce_product\Entity\ProductVariation' does not have a method 'getCurrentUserId' in Drupal\Core\Field\FieldConfigBase->getDefaultValue() (line 397 file /app/web/core/lib/Drupal/Core/Field/FieldConfigBase.php).

And when tried to save it:

Column 'uid' cannot be null: INSERT INTO {commerce_product_variation_field_data} …

Proposed resolution

There should be update hook converting default_value_callback to getDefaultEntityOwner.

Workaround

Just change:

default_value_callback: 'Drupal\commerce_product\Entity\ProductVariation::getCurrentUserId'

to:

default_value_callback: 'Drupal\commerce_product\Entity\ProductVariation::getDefaultEntityOwner'

In both core.base_field_override.commerce_product_variation.*.uid.yml and core.base_field_override.commerce_product.*.uid.yml.

🐛 Bug report
Status

Needs review

Version

3.0

Component

Product

Created by

🇨🇿Czech Republic Honza Pobořil

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024