diff --git a/core/lib/Drupal/Component/PhpStorage/FileStorage.php b/core/lib/Drupal/Component/PhpStorage/FileStorage.php
index b8c3aad042dd39379a73ae1faaa214a8fac10883..d588af4780cc7f46923d3fcadcc3e6b75c0f8117 100644
--- a/core/lib/Drupal/Component/PhpStorage/FileStorage.php
+++ b/core/lib/Drupal/Component/PhpStorage/FileStorage.php
@@ -53,7 +53,10 @@ public function load($name) {
    */
   public function save($name, $code) {
     $path = $this->getFullPath($name);
-    mkdir(dirname($path), 0700, TRUE);
+    $dir = dirname($path);
+    if (!file_exists($dir)) {
+      mkdir($dir, 0700, TRUE);
+    }
     return (bool) file_put_contents($path, $code);
   }