mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +00:00
Update packages and various code for laravel 9
This commit is contained in:
@@ -27,7 +27,6 @@ use Crypt;
|
|||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Storage;
|
use Storage;
|
||||||
|
|
||||||
@@ -61,11 +60,10 @@ class ScanAttachments extends Command
|
|||||||
$disk = Storage::disk('upload');
|
$disk = Storage::disk('upload');
|
||||||
/** @var Attachment $attachment */
|
/** @var Attachment $attachment */
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
$fileName = $attachment->fileName();
|
$fileName = $attachment->fileName();
|
||||||
try {
|
$encryptedContent = $disk->get($fileName);
|
||||||
$encryptedContent = $disk->get($fileName);
|
if (null === $encryptedContent) {
|
||||||
} catch (FileNotFoundException $e) {
|
Log::error(sprintf('No content for attachment #%d under filename "%s"', $attachment->id, $fileName));
|
||||||
$this->error(sprintf('Could not find data for attachment #%d: %s', $attachment->id, $e->getMessage()));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Console\Commands;
|
namespace FireflyIII\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Storage;
|
use Storage;
|
||||||
|
|
||||||
@@ -51,7 +50,6 @@ class VerifySecurityAlerts extends Command
|
|||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
* @throws FileNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
@@ -28,7 +28,6 @@ use FireflyIII\Models\Attachment;
|
|||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Contracts\Encryption\EncryptException;
|
use Illuminate\Contracts\Encryption\EncryptException;
|
||||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
|
||||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@@ -58,8 +57,8 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->maxUploadSize = (int)config('firefly.maxUploadSize');
|
$this->maxUploadSize = (int) config('firefly.maxUploadSize');
|
||||||
$this->allowedMimes = (array)config('firefly.allowedMimes');
|
$this->allowedMimes = (array) config('firefly.allowedMimes');
|
||||||
$this->errors = new MessageBag;
|
$this->errors = new MessageBag;
|
||||||
$this->messages = new MessageBag;
|
$this->messages = new MessageBag;
|
||||||
$this->attachments = new Collection;
|
$this->attachments = new Collection;
|
||||||
@@ -77,15 +76,10 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
*/
|
*/
|
||||||
public function getAttachmentContent(Attachment $attachment): string
|
public function getAttachmentContent(Attachment $attachment): string
|
||||||
{
|
{
|
||||||
$encryptedData = '';
|
$encryptedData = (string) $this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));
|
||||||
try {
|
|
||||||
$encryptedData = $this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));
|
|
||||||
} catch (FileNotFoundException $e) {
|
|
||||||
Log::error($e->getMessage());
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
$unencryptedData = Crypt::decrypt($encryptedData); // verified
|
$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()));
|
Log::error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
|
||||||
$unencryptedData = $encryptedData;
|
$unencryptedData = $encryptedData;
|
||||||
}
|
}
|
||||||
@@ -103,7 +97,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
*/
|
*/
|
||||||
public function getAttachmentLocation(Attachment $attachment): string
|
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);
|
$this->attachments->push($attachment);
|
||||||
|
|
||||||
$name = e($file->getClientOriginalName()); // add message:
|
$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);
|
$this->messages->add('attachments', $msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +324,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
$result = true;
|
$result = true;
|
||||||
|
|
||||||
if (!in_array($mime, $this->allowedMimes, 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);
|
$this->errors->add('attachments', $msg);
|
||||||
Log::error($msg);
|
Log::error($msg);
|
||||||
|
|
||||||
@@ -355,7 +349,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
$name = e($file->getClientOriginalName());
|
$name = e($file->getClientOriginalName());
|
||||||
$result = true;
|
$result = true;
|
||||||
if ($size > $this->maxUploadSize) {
|
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);
|
$this->errors->add('attachments', $msg);
|
||||||
Log::error($msg);
|
Log::error($msg);
|
||||||
|
|
||||||
@@ -387,7 +381,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
}
|
}
|
||||||
$result = false;
|
$result = false;
|
||||||
if ($count > 0) {
|
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);
|
$this->errors->add('attachments', $msg);
|
||||||
Log::error($msg);
|
Log::error($msg);
|
||||||
$result = true;
|
$result = true;
|
||||||
|
@@ -31,7 +31,6 @@ use FireflyIII\Models\Attachment;
|
|||||||
use FireflyIII\Models\Note;
|
use FireflyIII\Models\Note;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -101,12 +100,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
|||||||
$unencryptedContent = '';
|
$unencryptedContent = '';
|
||||||
|
|
||||||
if ($disk->exists($file)) {
|
if ($disk->exists($file)) {
|
||||||
$encryptedContent = '';
|
$encryptedContent = (string) $disk->get($file);
|
||||||
try {
|
|
||||||
$encryptedContent = $disk->get($file);
|
|
||||||
} catch (FileNotFoundException $e) {
|
|
||||||
Log::error($e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$unencryptedContent = Crypt::decrypt($encryptedContent); // verified
|
$unencryptedContent = Crypt::decrypt($encryptedContent); // verified
|
||||||
@@ -129,7 +123,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
|||||||
{
|
{
|
||||||
$note = $attachment->notes()->first();
|
$note = $attachment->notes()->first();
|
||||||
if (null !== $note) {
|
if (null !== $note) {
|
||||||
return (string)$note->text;
|
return (string) $note->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -175,20 +169,20 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
|||||||
$attachment->title = $data['title'];
|
$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'];
|
$attachment->filename = $data['filename'];
|
||||||
}
|
}
|
||||||
// update model (move attachment)
|
// update model (move attachment)
|
||||||
// should be validated already:
|
// should be validated already:
|
||||||
if (array_key_exists('attachable_type', $data) && array_key_exists('attachable_id', $data)) {
|
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->attachable_type = sprintf('FireflyIII\\Models\\%s', $data['attachable_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$attachment->save();
|
$attachment->save();
|
||||||
$attachment->refresh();
|
$attachment->refresh();
|
||||||
if (array_key_exists('notes', $data)) {
|
if (array_key_exists('notes', $data)) {
|
||||||
$this->updateNote($attachment, (string)$data['notes']);
|
$this->updateNote($attachment, (string) $data['notes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $attachment;
|
return $attachment;
|
||||||
|
@@ -97,12 +97,16 @@
|
|||||||
"league/commonmark": "2.*",
|
"league/commonmark": "2.*",
|
||||||
"league/csv": "^9.7",
|
"league/csv": "^9.7",
|
||||||
"league/fractal": "0.*",
|
"league/fractal": "0.*",
|
||||||
|
"nunomaduro/collision": "^6.1",
|
||||||
"pragmarx/google2fa": "^8.0",
|
"pragmarx/google2fa": "^8.0",
|
||||||
"predis/predis": "^1.1",
|
"predis/predis": "^1.1",
|
||||||
"psr/log": "<3",
|
"psr/log": "<3",
|
||||||
"ramsey/uuid": "^4.2",
|
"ramsey/uuid": "^4.2",
|
||||||
"rcrowe/twigbridge": "^0.14",
|
"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": {
|
"require-dev": {
|
||||||
"barryvdh/laravel-debugbar": "^3.6",
|
"barryvdh/laravel-debugbar": "^3.6",
|
||||||
|
937
composer.lock
generated
937
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -33,21 +33,7 @@ return [
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'default' => env('FILESYSTEM_DRIVER', 'local'),
|
'default' => env('FILESYSTEM_DISK', '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'),
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Filesystem Disks
|
| Filesystem Disks
|
||||||
|
Reference in New Issue
Block a user