By andypost on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
9.5.x
Introduced in version:
9.5.0
Issue links:
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:
- If you were just using
DependencySerializationTraitno action is required, it will continue to work. - If you're using
_serviceIdas part of a__sleepmethod, 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... - 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