From 6dd95757bf033b4b80946784ba2e3ad7ee7c64ad Mon Sep 17 00:00:00 2001
From: Kasper Garnaes <kasper.garnaes@gmail.com>
Date: Thu, 25 Jan 2018 11:29:34 +0100
Subject: [PATCH] Avoid PHP warning when clearing the root path cache

---
 core/lib/Drupal/Core/Path/AliasManager.php             | 2 +-
 core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php
index 6773e79..75c258f 100644
--- a/core/lib/Drupal/Core/Path/AliasManager.php
+++ b/core/lib/Drupal/Core/Path/AliasManager.php
@@ -281,7 +281,7 @@ protected function pathAliasWhitelistRebuild($path = NULL) {
     // When paths are inserted, only rebuild the whitelist if the path has a top
     // level component which is not already in the whitelist.
     if (!empty($path)) {
-      if ($this->whitelist->get(strtok($path, '/'))) {
+      if ($path !== '/' && $this->whitelist->get(strtok($path, '/'))) {
         return;
       }
     }
diff --git a/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php b/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php
index ffd52dc..4f4d1c3 100644
--- a/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php
@@ -474,6 +474,9 @@ public function testCacheClear() {
 
     // Clear non-existent source.
     $this->aliasManager->cacheClear('non-existent');
+
+    // Clear root path.
+    $this->aliasManager->cacheClear('/');
   }
 
   /**
-- 
2.15.0

