Verified Commit 77d7fb65 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3310271 by catch, longwave, benjifisher, samuel.mortenson: Container...

Issue #3310271 by catch, longwave, benjifisher, samuel.mortenson: Container serialization must handle string services in 9.x
parent b3b6c07d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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;
+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'));
  }

}