From fc7d4a51d2496bcbb350a76e53688fb08ccb3a55 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Wed, 28 Oct 2020 12:18:20 +0000
Subject: [PATCH] Issue #3177541 by alexpott, andypost: stream_open() needs to
 cope with a failure in \Drupal\Core\StreamWrapper\LocalStream::getLocalPath()
 better

---
 core/lib/Drupal/Core/StreamWrapper/LocalStream.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
index 67ab36a56a33..f9a57ab30f4c 100644
--- a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
+++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
@@ -163,6 +163,12 @@ protected function getLocalPath($uri = NULL) {
   public function stream_open($uri, $mode, $options, &$opened_path) {
     $this->uri = $uri;
     $path = $this->getLocalPath();
+    if ($path === FALSE) {
+      if ($options & STREAM_REPORT_ERRORS) {
+        trigger_error('stream_open() filename cannot be empty', E_USER_WARNING);
+      }
+      return FALSE;
+    }
     $this->handle = ($options & STREAM_REPORT_ERRORS) ? fopen($path, $mode) : @fopen($path, $mode);
 
     if ((bool) $this->handle && $options & STREAM_USE_PATH) {
-- 
GitLab