Skip to content

Commit

Permalink
WP_In_Memory_Filesystem: Prevent fatal error when a streaming method …
Browse files Browse the repository at this point in the history
…is called without creating a streamer first
  • Loading branch information
adamziel committed Jan 1, 2025
1 parent a3b63e3 commit 8bc9dc3
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/WordPress/Filesystem/WP_In_Memory_Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,40 @@ public function open_file_stream($path) {
}

public function next_file_chunk() {
if(!$this->last_file_reader) {
return false;
}
return $this->last_file_reader->next_bytes();
}

public function get_file_chunk() {
if(!$this->last_file_reader) {
return false;
}
return $this->last_file_reader->get_bytes();
}

public function get_streamed_file_length() {
if(!$this->last_file_reader) {
return false;
}
return $this->last_file_reader->length();
}

public function get_error_message() {
if(!$this->last_file_reader) {
return false;
}
return $this->last_file_reader->get_last_error();
}

public function close_file_stream() {
if($this->last_file_reader) {
$this->last_file_reader->close();
$this->last_file_reader = null;
if(!$this->last_file_reader) {
return false;
}
$this->last_file_reader->close();
$this->last_file_reader = null;
return true;
}

public function rename($old_path, $new_path) {
Expand Down

0 comments on commit 8bc9dc3

Please sign in to comment.