Change record status: 
Project: 
Introduced in branch: 
9.5.x
Introduced in version: 
9.5.0
Description: 

Starting in 9.5.0, Drupal no longer dynamically adds a _serviceId property to objects in the container. If you were using this property you have a couple of options going forward:

  1. If you were just using DependencySerializationTrait no action is required, it will continue to work.
  2. If you're using _serviceId as part of a __sleep method, you should instead exclude the service from the returned keys and explicitly replace the property in __wake. Views provides a good example of this sort of change https://git.drupalcode.org/project/drupal/-/commit/d83d8eb4dfa214164c73e...
  3. If you need to resolve a service to a service ID, you can use new methods on the service container and kernel. The code would look something like this.
    $map = $container->get('kernel')->getServiceIdMapping();
    $hash = $container->generateServiceIdHash($service);
    $serviceId = $map[$i] ?? NULL;
    

Note: This change is required because as of PHP 8.2 warns about accessing dynamic properties, see https://wiki.php.net/rfc/deprecate_dynamic_properties

Impacts: 
Module developers