Update packages and various code for laravel 9

This commit is contained in:
James Cole 2022-03-19 08:10:42 +01:00
parent 45d99aa456
commit 5ca0a9f75a
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
7 changed files with 750 additions and 261 deletions

View File

@ -27,7 +27,6 @@ use Crypt;
use FireflyIII\Models\Attachment;
use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Log;
use Storage;
@ -61,11 +60,10 @@ class ScanAttachments extends Command
$disk = Storage::disk('upload');
/** @var Attachment $attachment */
foreach ($attachments as $attachment) {
$fileName = $attachment->fileName();
try {
$encryptedContent = $disk->get($fileName);
} catch (FileNotFoundException $e) {
$this->error(sprintf('Could not find data for attachment #%d: %s', $attachment->id, $e->getMessage()));
$fileName = $attachment->fileName();
$encryptedContent = $disk->get($fileName);
if (null === $encryptedContent) {
Log::error(sprintf('No content for attachment #%d under filename "%s"', $attachment->id, $fileName));
continue;
}
try {

View File

@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Log;
use Storage;
@ -51,7 +50,6 @@ class VerifySecurityAlerts extends Command
* Execute the console command.
*
* @return int
* @throws FileNotFoundException
*/
public function handle(): int
{

View File

@ -28,7 +28,6 @@ use FireflyIII\Models\Attachment;
use FireflyIII\Models\PiggyBank;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\EncryptException;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
@ -58,8 +57,8 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
public function __construct()
{
$this->maxUploadSize = (int)config('firefly.maxUploadSize');
$this->allowedMimes = (array)config('firefly.allowedMimes');
$this->maxUploadSize = (int) config('firefly.maxUploadSize');
$this->allowedMimes = (array) config('firefly.allowedMimes');
$this->errors = new MessageBag;
$this->messages = new MessageBag;
$this->attachments = new Collection;
@ -77,15 +76,10 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
public function getAttachmentContent(Attachment $attachment): string
{
$encryptedData = '';
try {
$encryptedData = $this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));
} catch (FileNotFoundException $e) {
Log::error($e->getMessage());
}
$encryptedData = (string) $this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));
try {
$unencryptedData = Crypt::decrypt($encryptedData); // verified
} catch (DecryptException | FileNotFoundException $e) {
} catch (DecryptException $e) {
Log::error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
$unencryptedData = $encryptedData;
}
@ -103,7 +97,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
public function getAttachmentLocation(Attachment $attachment): string
{
return sprintf('%sat-%d.data', DIRECTORY_SEPARATOR, (int)$attachment->id);
return sprintf('%sat-%d.data', DIRECTORY_SEPARATOR, (int) $attachment->id);
}
/**
@ -273,7 +267,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$this->attachments->push($attachment);
$name = e($file->getClientOriginalName()); // add message:
$msg = (string)trans('validation.file_attached', ['name' => $name]);
$msg = (string) trans('validation.file_attached', ['name' => $name]);
$this->messages->add('attachments', $msg);
}
@ -330,7 +324,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$result = true;
if (!in_array($mime, $this->allowedMimes, true)) {
$msg = (string)trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]);
$msg = (string) trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]);
$this->errors->add('attachments', $msg);
Log::error($msg);
@ -355,7 +349,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$name = e($file->getClientOriginalName());
$result = true;
if ($size > $this->maxUploadSize) {
$msg = (string)trans('validation.file_too_large', ['name' => $name]);
$msg = (string) trans('validation.file_too_large', ['name' => $name]);
$this->errors->add('attachments', $msg);
Log::error($msg);
@ -387,7 +381,7 @@ class AttachmentHelper implements AttachmentHelperInterface
}
$result = false;
if ($count > 0) {
$msg = (string)trans('validation.file_already_attached', ['name' => $name]);
$msg = (string) trans('validation.file_already_attached', ['name' => $name]);
$this->errors->add('attachments', $msg);
Log::error($msg);
$result = true;

View File

@ -31,7 +31,6 @@ use FireflyIII\Models\Attachment;
use FireflyIII\Models\Note;
use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
use Log;
@ -101,12 +100,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
$unencryptedContent = '';
if ($disk->exists($file)) {
$encryptedContent = '';
try {
$encryptedContent = $disk->get($file);
} catch (FileNotFoundException $e) {
Log::error($e->getMessage());
}
$encryptedContent = (string) $disk->get($file);
try {
$unencryptedContent = Crypt::decrypt($encryptedContent); // verified
@ -129,7 +123,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
{
$note = $attachment->notes()->first();
if (null !== $note) {
return (string)$note->text;
return (string) $note->text;
}
return null;
@ -175,20 +169,20 @@ class AttachmentRepository implements AttachmentRepositoryInterface
$attachment->title = $data['title'];
}
if (array_key_exists('filename', $data) && '' !== (string)$data['filename'] && $data['filename'] !== $attachment->filename) {
if (array_key_exists('filename', $data) && '' !== (string) $data['filename'] && $data['filename'] !== $attachment->filename) {
$attachment->filename = $data['filename'];
}
// update model (move attachment)
// should be validated already:
if (array_key_exists('attachable_type', $data) && array_key_exists('attachable_id', $data)) {
$attachment->attachable_id = (int)$data['attachable_id'];
$attachment->attachable_id = (int) $data['attachable_id'];
$attachment->attachable_type = sprintf('FireflyIII\\Models\\%s', $data['attachable_type']);
}
$attachment->save();
$attachment->refresh();
if (array_key_exists('notes', $data)) {
$this->updateNote($attachment, (string)$data['notes']);
$this->updateNote($attachment, (string) $data['notes']);
}
return $attachment;

View File

@ -97,12 +97,16 @@
"league/commonmark": "2.*",
"league/csv": "^9.7",
"league/fractal": "0.*",
"nunomaduro/collision": "^6.1",
"pragmarx/google2fa": "^8.0",
"predis/predis": "^1.1",
"psr/log": "<3",
"ramsey/uuid": "^4.2",
"rcrowe/twigbridge": "^0.14",
"spatie/data-transfer-object": "^3.7"
"spatie/data-transfer-object": "^3.7",
"spatie/laravel-ignition": "^1.0",
"symfony/http-client": "^6.0",
"symfony/mailgun-mailer": "^6.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.6",

937
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -33,21 +33,7 @@ return [
|
*/
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks