Getting Object of class Drupal\user\Entity\User could not be converted to strin

Created on 12 November 2024, 4 months ago

Problem/Motivation

While accessing the User landing page (/user/uid) getting below error:
Error: Object of class Drupal\user\Entity\User could not be converted to string in Drupal\Core\Entity\EntityStorageBase->buildCacheId() (line 142 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

#0 /core/lib/Drupal/Core/Entity/EntityStorageBase.php(182): Drupal\Core\Entity\EntityStorageBase->buildCacheId()
#1 /core/lib/Drupal/Core/Entity/EntityStorageBase.php(282): Drupal\Core\Entity\EntityStorageBase->getFromStaticCache()
#2 /core/lib/Drupal/Core/Entity/EntityStorageBase.php(262): Drupal\Core\Entity\EntityStorageBase->loadMultiple()
#3 /core/lib/Drupal/Core/Entity/EntityBase.php(503): Drupal\Core\Entity\EntityStorageBase->load()
#4 /modules/contrib/scheduler/src/Access/SchedulerRouteAccess.php(72): Drupal\Core\Entity\EntityBase::load()
#5 [internal function]: Drupal\scheduler\Access\SchedulerRouteAccess->access()
#6 /core/lib/Drupal/Core/Access/CustomAccessCheck.php(84): call_user_func_array()
#7 [internal function]: Drupal\Core\Access\CustomAccessCheck->access()

Steps to reproduce

Updated Scheduler module from 8.x-1.5 to 2.1.0 and try to access user landing page.

Proposed resolution

In scheduler/src/Access/SchedulerRouteAccess.php::access function, $user_being_viewed = $route_match->getParameter('user'); is loading user object instead of uid, instead of calling getParameter() we need to use getRawParameter() function which load raw user id value.

🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇮🇳India ramreddy.kancherla

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

Comments & Activities

  • Issue created by @ramreddy.kancherla
  • 🇮🇳India ramreddy.kancherla

    Patch file to fix the problem.

  • 🇬🇧United Kingdom jonathan1055

    Hi ramreddy.kancherla
    Please could you tell me what Drupal core version you are using? It was not a problem when that code was written, but maybe things have changed since then.

  • 🇨🇭Switzerland ayalon

    I have the same error for all user login in. Drupal 10.3.8

  • 🇬🇧United Kingdom jonathan1055

    I've tried but I cannot replicate this error. Here are the steps I have followed:

    1. Install clean Drupal 10.3.8 (or 10.4-dev)
    2. Login as admin and create a user
    3. Install Scheduler 8.x-1.5
    4. Use Scheduler OK
    5. Update to Scheduler 2.1.0
    6. Run necessary database updates (8) via admin
    7. Log out - OK
    8. Log in as ordinary user - OK

    Do you know of anything else which might be interferring with your site?

  • Status changed to Closed: cannot reproduce about 2 months ago
  • 🇬🇧United Kingdom jonathan1055

    Closing this as no response in two months.
    You are welcome to re-open if you can provide detailed steps to reproduce the problem.

Production build 0.71.5 2024