Call to a member function error

Created on 8 October 2024, 3 months ago

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

💬 Support request
Status

Active

Version

2.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

  • Issue created by @pearls
  • 🇮🇳India mohd sahzad

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

  • Merge request !2fixed Call to a member function error → (Open) created by mohd sahzad
  • 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).
    
  • 🇮🇳India kulpratap2002

    Working on it.

  • 🇮🇳India kulpratap2002

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

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

  • 🇮🇳India kulpratap2002

    Please check.

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

Production build 0.71.5 2024