Skip to content

Commit

Permalink
Only define "str_to_stream" if it doesn't exist yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
fancycode committed Apr 8, 2024
1 parent 7bd5bd2 commit 260d07c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 7 additions & 5 deletions lib/Controller/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 260d07c

Please sign in to comment.