From 260d07c7b4ea2033d79c4b451c5915d0a878044c Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Mon, 8 Apr 2024 13:19:02 +0200 Subject: [PATCH] Only define "str_to_stream" if it doesn't exist yet. --- lib/Controller/ApiController.php | 12 +++++++----- lib/Controller/DownloadController.php | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 2f534839..7b03e4b0 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -53,11 +53,13 @@ use OCP\Share\IShare; use Psr\Log\LoggerInterface; -function str_to_stream(string $string) { - $stream = fopen('php://memory', 'r+'); - fwrite($stream, $string); - rewind($stream); - return $stream; +if (!function_exists(__NAMESPACE__ . '\str_to_stream')) { + function str_to_stream(string $string) { + $stream = fopen('php://memory', 'r+'); + fwrite($stream, $string); + rewind($stream); + return $stream; + } } class ApiController extends OCSController { diff --git a/lib/Controller/DownloadController.php b/lib/Controller/DownloadController.php index 9e0cc575..f8936572 100644 --- a/lib/Controller/DownloadController.php +++ b/lib/Controller/DownloadController.php @@ -39,11 +39,13 @@ use OCP\IURLGenerator; use OCP\IUserSession; -function str_to_stream(string $string) { - $stream = fopen('php://memory', 'r+'); - fwrite($stream, $string); - rewind($stream); - return $stream; +if (!function_exists(__NAMESPACE__ . '\str_to_stream')) { + function str_to_stream(string $string) { + $stream = fopen('php://memory', 'r+'); + fwrite($stream, $string); + rewind($stream); + return $stream; + } } class DownloadController extends Controller {