Problem/Motivation

I set the lock field option for a Boolean Field Type in user entity, but even if I don't touch the field, I get the following PHP error when I do anything else with user.

Error: Call to a member function getFieldDefinition() on array in lock_field_values_preprocess_field() (line 47 of /var/www/html/mysite/web/modules/contrib/lock_field_values/lock_field_values.module).

Any idea, please? Thanks

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

pearls created an issue. See original summary.

mohd sahzad made their first commit to this issue’s fork.

pearls’s picture

Thanks mohd. Tested. Now we have 2 issues. Here's the log.

Deprecated function: reset(): Calling reset() on an object is deprecated in lock_field_values_preprocess_field() (line 47 of /var/www/html/mysite/web/modules/contrib/lock_field_values/lock_field_values.module)

#0 /var/www/html/mysite/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 [internal function]: _drupal_error_handler()
#2 /var/www/html/mysite/web/modules/contrib/lock_field_values/lock_field_values.module(47): reset()
#3 [internal function]: lock_field_values_preprocess_field()
#4 /var/www/html/mysite/web/core/lib/Drupal/Core/Theme/ThemeManager.php(261): call_user_func_array()
#5 /var/www/html/mysite/web/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render()
#6 /var/www/html/mysite/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender()
#7 /var/www/html/mysite/web/core/modules/node/node.module(550): Drupal\Core\Render\Renderer->render()
.....................
Error: Call to undefined method Drupal\Core\Field\BaseFieldDefinition::getFieldDefinition() in lock_field_values_preprocess_field() (line 50 of /var/www/html/mysite/web/modules/contrib/lock_field_values/lock_field_values.module).
kul.pratap’s picture

Assigned: Unassigned » kul.pratap

Working on it.

kul.pratap’s picture

@pearls What do you mean by "I get the following PHP error when I do anything else with user" can you please ellaborate what are you doing with the user because i can't able to reproduce the issue in my site everything is working right on the User Interface.

pearls’s picture

There is a boolean field in user entity that triggers role assignment when it'ss value is on.There are also text fields that should not be changed.
In some scenarios, the administrator needs to lock these field for some users. I use the module for these fields. However, even if the administrator does not touch any of these field, It keeps giving the errors mentioned in the previous comment.
@kul, Thanks for support .

kul.pratap’s picture

Assigned: kul.pratap » Unassigned
Status: Active » Needs review

Please check.

pearls’s picture

Tested.
After MR!2, "Lock field values ​​checkbox" disappeared .
You see that the Lock Values ​​Checkbox does not appear when you try to edit a member profile.

divyansh.gupta’s picture

Status: Needs review » Needs work

The original error no longer appears, which is great but it seems that the “Lock field values” checkbox is missing when editing a user profile. This may have been unintentionally affected by the recent changes.
So moving this issue back to NW, so that someone can resolve this bug caused!!

justcaldwell’s picture

Status: Needs work » Postponed (maintainer needs more info)

I'm unable to replicate this error in either Drupal 10 or 11. I tested with text and boolean fields added to both Basic Page nodes and a user profile. The current MR is not viable in its current form—hook_field_widget_form_alter() was removed in Drupal 10.

To go any further, I think we'll need detailed instructions for reproducing the error, including Drupal core version, PHP version, etc.