Skip to content
Snippets Groups Projects

Don't prevent destruction without preHandle having been run.

Closes #3412556

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 687 687 public function terminate(Request $request, Response $response) {
    688 688 // Only run terminate() when essential services have been set up properly
    689 689 // by preHandle() before.
    690 if (FALSE === $this->prepared) {
    691 return;
    692 }
    693
    694 690 if ($this->getHttpKernel() instanceof TerminableInterface) {
    695 $this->getHttpKernel()->terminate($request, $response);
    691 if (TRUE === $this->prepared) {
    692 $this->getHttpKernel()->terminate($request, $response);
    693 }
    694 // However always allow any instantiated services to destruct.
    695 $this->container->get('kernel_destruct_subscriber')->onKernelTerminate();
    • Comment on lines +694 to +695

      How about adding something like

      $container->setParameter('kernel.services_for_destruction', array_keys($services));

      to \Drupal\Core\DependencyInjection\Compiler\RegisterServicesForDestructionPass

      And then inlining the code...

      Suggested change
      694 // However always allow any instantiated services to destruct.
      695 $this->container->get('kernel_destruct_subscriber')->onKernelTerminate();
      694 // Always allow any instantiated services to destruct.
      695 // @see \Drupal\Core\DependencyInjection\Compiler\RegisterServicesForDestructionPass
      696 foreach ($this->container->getParameter('kernel.services_for_destruction') as $service_id) {
      697 // Check if the service was initialized during this request, destruction
      698 // is not necessary if the service was not used.
      699 if ($this->container->initialized($service_id)) {
      700 $service = $this->container->get($service_id);
      701 $service->destruct();
      702 }
      703 }

      We also should file a follow to replace the tag with checking if the service implements \Drupal\Core\DestructableInterface

    • catch changed this line in version 18 of the diff

      changed this line in version 18 of the diff

    • Please register or sign in to reply
  • catch added 2 commits

    added 2 commits

    • 673d6edd - Inline the logic from KernelDestructionSubscriber
    • d14122d5 - Remove cruft.

    Compare with previous version

  • catch added 1 commit

    added 1 commit

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading