diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index db773ed2832cd35695dca2c44aecfe11322c0c77..3f53d04a3b8414b503d59997ef68ad278bd1987c 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 7370491816b526659a088f68d3325921cb4fbf8e..722bdd24510a619e097902efbf0e35ef3c7092cd 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); } }