Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294268

fopen() error in stream_wrappers.inc on PHP 8

$
0
0

Problem/Motivation

Upon update to php 8, the site started throwing an error on line 408. I'm sure this is related to PHP 8 not being very happy about potential null values. The following change stopped the error.

diff --git a/docroot/includes/stream_wrappers.inc b/docroot/includes/stream_wrappers.inc
index 31101674..f67ab42e 100644
--- a/docroot/includes/stream_wrappers.inc
+++ b/docroot/includes/stream_wrappers.inc
@@ -405,7 +405,11 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface
   public function stream_open($uri, $mode, $options, &$opened_path) {
     $this->uri = $uri;
     $path = $this->getLocalPath();
-    $this->handle = ($options & STREAM_REPORT_ERRORS) ? fopen($path, $mode) : @fopen($path, $mode);
+    if ($path){
+      $this->handle = ($options & STREAM_REPORT_ERRORS) ? fopen($path, $mode) : @fopen($path, $mode);
+    } else {
+      return FALSE;
+    }
 
     if ((bool) $this->handle && $options & STREAM_USE_PATH) {
       $opened_path = $path;

Viewing all articles
Browse latest Browse all 294268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>