From 16842fc2aa68293dddd6bd26e7d39db6dc1106a6 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Sat, 25 Mar 2017 10:48:26 +0000
Subject: [PATCH] Issue #2829346 by ekes, kentr, klausi: Allow repeated calls
 to DrupalKernel::setSitePath()

---
 core/lib/Drupal/Core/DrupalKernel.php                        | 2 +-
 .../KernelTests/Core/DrupalKernel/DrupalKernelTest.php       | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index db773ed2832c..3f53d04a3b84 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -410,7 +410,7 @@ public static function findSitePath(Request $request, $require_settings = TRUE,
    * {@inheritdoc}
    */
   public function setSitePath($path) {
-    if ($this->booted) {
+    if ($this->booted && $path !== $this->sitePath) {
       throw new \LogicException('Site path cannot be changed after calling boot()');
     }
     $this->sitePath = $path;
diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
index 7370491816b5..722bdd24510a 100644
--- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
+++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
@@ -184,6 +184,11 @@ public function testPreventChangeOfSitePath() {
       $pass = TRUE;
     }
     $this->assertTrue($pass, 'Throws LogicException if DrupalKernel::setSitePath() is called after boot');
+
+    // Ensure no LogicException if DrupalKernel::setSitePath() is called with
+    // identical path after boot.
+    $path = $kernel->getSitePath();
+    $kernel->setSitePath($path);
   }
 
 }
-- 
GitLab