Deprecated getCurrentUserId has not been removed from base_field_override.

Created on 27 January 2025, 4 months ago

Problem/Motivation

Base field override configs can still have deprecated default value callbacks 'Drupal\consumers\Entity\Consumer:getCurrentUserId' which will throw the following error message when adding new consumer:

The website encountered an unexpected error. Try again later.
TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, class Drupal\consumers\Entity\Consumer does not have a method "getCurrentUserId" in call_user_func() (line 431 of core/lib/Drupal/Core/Field/FieldConfigBase.php).

Proposed resolution

Implement update hook to remove the deprecated default value call back getCurrentUserIdand replace with getDefaultEntityOwner

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States alfattal Minnesota

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

Comments & Activities

  • Issue created by @alfattal
  • 🇺🇸United States alfattal Minnesota

    Workaround

    Just change:

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

    to:

    default_value_callback: 'Drupal\commerce_product\Entity\ProductVariation::getDefaultEntityOwner'
    In config/default/core.base_field_override.consumer.consumer.owner_id.yml

  • With a fresh setup, I attempted to reproduce the issue on my system but encountered an unexpected error when trying to add a new consumer with any website.

    @alfattal Could you please provide more details or steps to help reproduce the issue consistently? Let me know if there are specific configurations or scenarios I might have missed.

  • 🇺🇸United States alfattal Minnesota

    @kushagra.goyal Your comment is confusing. You mentioned that you've attempted to reproduce the issue and got the error that I already mentioned in this ticket, but then you are asking for testing steps to reproduce which you already did!

    Nevertheless, here are the steps:

    On a fresh or old Drupal setup, check the default_value_callback in the config file core.base_field_override.consumer.consumer.owner_id.yml. If it has the deprecated call back that ends with getCurrentUserId, then it will throw the error.

Production build 0.71.5 2024