Remove safe methods.

This commit is contained in:
James Cole
2025-05-11 14:08:32 +02:00
parent 145e8d23f0
commit 84779b8d02
65 changed files with 166 additions and 166 deletions

View File

@@ -118,7 +118,7 @@ class AttachmentHelper implements AttachmentHelperInterface
public function saveAttachmentFromApi(Attachment $attachment, string $content): bool
{
Log::debug(sprintf('Now in %s', __METHOD__));
$resource = \Safe\tmpfile();
$resource = tmpfile();
if (false === $resource) {
Log::error('Cannot create temp-file for file upload.');
@@ -133,17 +133,17 @@ class AttachmentHelper implements AttachmentHelperInterface
$path = stream_get_meta_data($resource)['uri'];
Log::debug(sprintf('Path is %s', $path));
$result = \Safe\fwrite($resource, $content);
$result = fwrite($resource, $content);
if (false === $result) {
Log::error('Could not write temp file.');
return false;
}
Log::debug(sprintf('Wrote %d bytes to temp file.', $result));
$finfo = \Safe\finfo_open(FILEINFO_MIME_TYPE);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
if (false === $finfo) {
Log::error('Could not open finfo.');
\Safe\fclose($resource);
fclose($resource);
return false;
}
@@ -151,7 +151,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$allowedMime = config('firefly.allowedMimes');
if (!in_array($mime, $allowedMime, true)) {
Log::error(sprintf('Mime type %s is not allowed for API file upload.', $mime));
\Safe\fclose($resource);
fclose($resource);
return false;
}
@@ -163,7 +163,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$this->uploadDisk->put($file, $content);
// update attachment.
$attachment->md5 = (string) \Safe\md5_file($path);
$attachment->md5 = (string) md5_file($path);
$attachment->mime = $mime;
$attachment->size = strlen($content);
$attachment->uploaded = true;
@@ -225,7 +225,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$attachment = new Attachment(); // create Attachment object.
$attachment->user()->associate($user);
$attachment->attachable()->associate($model);
$attachment->md5 = (string) \Safe\md5_file($file->getRealPath());
$attachment->md5 = (string) md5_file($file->getRealPath());
$attachment->filename = $file->getClientOriginalName();
$attachment->mime = $file->getMimeType();
$attachment->size = $file->getSize();
@@ -333,7 +333,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
protected function hasFile(UploadedFile $file, Model $model): bool
{
$md5 = \Safe\md5_file($file->getRealPath());
$md5 = md5_file($file->getRealPath());
$name = $file->getClientOriginalName();
$class = $model::class;
$count = 0;