Profile: Field field_profile_first_name is unknown

Created on 29 July 2021, over 3 years ago
Updated 11 November 2023, about 1 year ago

Problem/Motivation

There are 2 profile types on my site:
1. Default (bundle='profile') - public user profile with some personal details.
2. Technical (bundle='fantastic_profile') - hidden profile that stores data for admins and accessible by admins only.

The problem is: when I try to update some details in technical profile and click Save - I'm getting wsod and a following error in the log:

Drupal\Core\Entity\EntityStorageException: Field field_profile_first_name is unknown. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of /var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

But technical profile does not have first/last name fields!? Why is this error triggered?

Steps to reproduce

1. Add another profile type so that user would have 2 profiles (you may add even more). Do not add first/last name fields to that new profile type.
2. Try to update/save second profile type - you will get an error.

Proposed resolution

I've noticed some inconsistency in the code: some functions check profile type/bundle, but others - not. For example social_profile_profile_presave() is triggered for all profile types, but can process default profile type only (bundle='profile').
So below I've attached the patch for couple of functions spotted by me, it covers issue described here.

Remaining tasks

Investigate the code and find other places with some specific profile processing and add profile bundle check to avoid any errors/confusions.

πŸ› Bug report
Status

Needs review

Version

12.0

Component

Code (back-end)

Created by

πŸ‡·πŸ‡ΊRussia i-grou

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

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