Loading core/lib/Drupal/Component/DependencyInjection/ServiceIdHashTrait.php +4 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ public function getServiceIdMappings(): array { $mapping = []; foreach ($this->getServiceIds() as $service_id) { if ($this->initialized($service_id) && $service_id !== 'service_container') { $mapping[$this->generateServiceIdHash($this->get($service_id))] = $service_id; $service = $this->get($service_id); if (is_object($service)) { $mapping[$this->generateServiceIdHash($service)] = $service_id; } } } return $mapping; Loading core/tests/Drupal/KernelTests/Core/DependencyInjection/StringSerializationTest.php 0 → 100644 +24 −0 Original line number Diff line number Diff line <?php namespace Drupal\KernelTests\Core\DependencyInjection; use Drupal\KernelTests\KernelTestBase; /** * Tests serialization of string services. * * @group DependencyInjection * @group legacy */ class StringSerializationTest extends KernelTestBase { /** * Tests that strings are not put into the container class mapping. */ public function testSerializeString() { $this->assertIsString($this->container->get('app.root')); $this->container->getServiceIdMappings(); $this->assertIsString($this->container->get('app.root')); } } Loading
core/lib/Drupal/Component/DependencyInjection/ServiceIdHashTrait.php +4 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ public function getServiceIdMappings(): array { $mapping = []; foreach ($this->getServiceIds() as $service_id) { if ($this->initialized($service_id) && $service_id !== 'service_container') { $mapping[$this->generateServiceIdHash($this->get($service_id))] = $service_id; $service = $this->get($service_id); if (is_object($service)) { $mapping[$this->generateServiceIdHash($service)] = $service_id; } } } return $mapping; Loading
core/tests/Drupal/KernelTests/Core/DependencyInjection/StringSerializationTest.php 0 → 100644 +24 −0 Original line number Diff line number Diff line <?php namespace Drupal\KernelTests\Core\DependencyInjection; use Drupal\KernelTests\KernelTestBase; /** * Tests serialization of string services. * * @group DependencyInjection * @group legacy */ class StringSerializationTest extends KernelTestBase { /** * Tests that strings are not put into the container class mapping. */ public function testSerializeString() { $this->assertIsString($this->container->get('app.root')); $this->container->getServiceIdMappings(); $this->assertIsString($this->container->get('app.root')); } }