spatie / laravel-backup

A package to backup your Laravel app
https://spatie.be/docs/laravel-backup
MIT License
5.65k stars 763 forks source link

Serialization of 'FTP\Connection' is not allowed while sending Notifications #1633

Closed nocodelab closed 10 months ago

nocodelab commented 1 year ago

Hello guys, I'm using laravel-backup 8.1 in a "almost" fresh Laravel 9 website. Backups are working fine but the notification is failing with this Serialization error.

Screenshot 2023-01-25 at 18 28 26

I'm using an FTP server as backup disk but I have the same issue if I set the destination as "local".

This is the stack trace:

`[2023-01-25 18:28:13] local.ERROR: Serialization of 'FTP\Connection' is not allowed {"exception":"[object] (Exception(code: 0): Serialization of 'FTP\Connection' is not allowed at /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Queue.php:158) [stacktrace]

0 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Queue.php(158): serialize()

1 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Queue.php(127): Illuminate\Queue\Queue->createObjectPayload()

2 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Queue.php(105): Illuminate\Queue\Queue->createPayloadArray()

3 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php(38): Illuminate\Queue\Queue->createPayload()

4 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Queue.php(57): Illuminate\Queue\SyncQueue->push()

5 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(591): Illuminate\Queue\Queue->pushOn()

6 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(515): Illuminate\Events\Dispatcher->queueHandler()

7 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(441): Illuminate\Events\Dispatcher->Illuminate\Events\{closure}()

8 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\Events\Dispatcher->Illuminate\Events\{closure}()

9 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(151): Illuminate\Events\Dispatcher->dispatch()

10 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(106): Illuminate\Notifications\NotificationSender->sendToNotifiable()

11 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\Notifications\NotificationSender->Illuminate\Notifications\{closure}()

12 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(109): Illuminate\Notifications\NotificationSender->withLocale()

13 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(79): Illuminate\Notifications\NotificationSender->sendNow()

14 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(39): Illuminate\Notifications\NotificationSender->send()

15 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/RoutesNotifications.php(18): Illuminate\Notifications\ChannelManager->send()

16 /var/www/html/vendor/spatie/laravel-backup/src/Notifications/EventHandler.php(30): Spatie\Backup\Notifications\Notifiable->notify()

17 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(421): Spatie\Backup\Notifications\EventHandler->Spatie\Backup\Notifications\{closure}()

18 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\Events\Dispatcher->Illuminate\Events\{closure}()

19 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(451): Illuminate\Events\Dispatcher->dispatch()

20 /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(311): event()

21 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(756): Spatie\Backup\Tasks\Backup\BackupJob->Spatie\Backup\Tasks\Backup\{closure}()

22 /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(313): rescue()

23 /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(296): Spatie\Backup\Tasks\Backup\BackupJob->sendNotification()

24 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(236): Spatie\Backup\Tasks\Backup\BackupJob->Spatie\Backup\Tasks\Backup\{closure}()

25 /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(304): Illuminate\Support\Collection->each()

26 /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(168): Spatie\Backup\Tasks\Backup\BackupJob->copyToBackupDestinations()

27 /var/www/html/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php(58): Spatie\Backup\Tasks\Backup\BackupJob->run()

28 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Spatie\Backup\Commands\BackupCommand->handle()

29 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

30 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()

31 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()

32 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(663): Illuminate\Container\BoundMethod::call()

33 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call()

34 /var/www/html/vendor/symfony/console/Command/Command.php(312): Illuminate\Console\Command->execute()

35 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(152): Symfony\Component\Console\Command\Command->run()

36 /var/www/html/vendor/spatie/laravel-backup/src/Commands/BaseCommand.php(28): Illuminate\Console\Command->run()

37 /var/www/html/vendor/symfony/console/Application.php(1022): Spatie\Backup\Commands\BaseCommand->run()

38 /var/www/html/vendor/symfony/console/Application.php(314): Symfony\Component\Console\Application->doRunCommand()

39 /var/www/html/vendor/symfony/console/Application.php(168): Symfony\Component\Console\Application->doRun()

40 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\Component\Console\Application->run()

41 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(155): Illuminate\Console\Application->run()

42 /var/www/html/artisan(37): Illuminate\Foundation\Console\Kernel->handle()

43 {main}

"} `

Any advice on how to solve the issue?

bcerati commented 1 year ago

Any idea?

freekmurze commented 1 year ago

I guess we need to unset unserializable things when sending the notification. I'd accept a PR that takes care of this.

spatie-bot commented 10 months ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.