spatie / laravel-backup

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

Cannot send notifications after upgrading to 7.X and PHP 8 #1315

Closed jpmurray closed 3 years ago

jpmurray commented 3 years ago

So I decided to upgrade a site to php 8 and ^7.0 of this package so I can leverage the Discord notification channel. Somehow, no notifications are going through anymore, not even the Slack one that used to work perfectly fine as of last night.

Here's the stack trace.

[2021-05-23 10:45:48] production.ERROR: There is no notification class that can handle event `Spatie\Backup\Events\BackupWasSuccessful`. {"exception":"[object] (Spatie\\Backup\\Exceptions\\NotificationCouldNotBeSent(code: 0): There is no notification class that can handle event `Spatie\\Backup\\Events\\BackupWasSuccessful`. at /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Exceptions/NotificationCouldNotBeSent.php:13)
[stacktrace]
#0 /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Notifications/EventHandler.php(50): Spatie\\Backup\\Exceptions\\NotificationCouldNotBeSent::noNotificationClassForEvent()
#1 /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Notifications/EventHandler.php(28): Spatie\\Backup\\Notifications\\EventHandler->determineNotification()
#2 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(392): Spatie\\Backup\\Notifications\\EventHandler->Spatie\\Backup\\Notifications\\{closure}()
#3 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(237): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}()
#4 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(450): Illuminate\\Events\\Dispatcher->dispatch()
#5 /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(288): event()
#6 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(656): Spatie\\Backup\\Tasks\\Backup\\BackupJob->Spatie\\Backup\\Tasks\\Backup\\{closure}()
#7 /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(290): rescue()
#8 /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(275): Spatie\\Backup\\Tasks\\Backup\\BackupJob->sendNotification()
#9 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(234): Spatie\\Backup\\Tasks\\Backup\\BackupJob->Spatie\\Backup\\Tasks\\Backup\\{closure}()
#10 /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(281): Illuminate\\Support\\Collection->each()
#11 /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(157): Spatie\\Backup\\Tasks\\Backup\\BackupJob->copyToBackupDestinations()
#12 /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php(54): Spatie\\Backup\\Tasks\\Backup\\BackupJob->run()
#13 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Spatie\\Backup\\Commands\\BackupCommand->handle()
#14 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#15 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#16 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#17 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Container/Container.php(614): Illuminate\\Container\\BoundMethod::call()
#18 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call()
#19 /home/forge/[SITE-REDACTED]/vendor/symfony/console/Command/Command.php(256): Illuminate\\Console\\Command->execute()
#20 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run()
#21 /home/forge/[SITE-REDACTED]/vendor/spatie/laravel-backup/src/Commands/BaseCommand.php(27): Illuminate\\Console\\Command->run()
#22 /home/forge/[SITE-REDACTED]/vendor/symfony/console/Application.php(971): Spatie\\Backup\\Commands\\BaseCommand->run()
#23 /home/forge/[SITE-REDACTED]/vendor/symfony/console/Application.php(290): Symfony\\Component\\Console\\Application->doRunCommand()
#24 /home/forge/[SITE-REDACTED]/vendor/symfony/console/Application.php(166): Symfony\\Component\\Console\\Application->doRun()
#25 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Console/Application.php(92): Symfony\\Component\\Console\\Application->run()
#26 /home/forge/[SITE-REDACTED]/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run()
#27 /home/forge/[SITE-REDACTED]/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#28 {main}
"} 

Only thing I did was upgrade to 7.x, then php 8. Now every notification the package tries to send ends up like this.

EDIT: the backups are running and uploading fine. Cleanup doesn't go through because error is thrown before anything, unless the backup process, if I'm seeing things right.

marechenok commented 3 years ago

There is new Notification classes:

        'notifications' => [
            \Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification::class => ['mail'],
            \Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFoundNotification::class => ['mail'],
            \Spatie\Backup\Notifications\Notifications\CleanupHasFailedNotification::class => ['mail'],
            \Spatie\Backup\Notifications\Notifications\BackupWasSuccessfulNotification::class => ['mail'],
            \Spatie\Backup\Notifications\Notifications\HealthyBackupWasFoundNotification::class => ['mail'],
            \Spatie\Backup\Notifications\Notifications\CleanupWasSuccessfulNotification::class => ['mail'],
        ],

Update your backup.php config file

jpmurray commented 3 years ago

Thank you @marechenok . I was so focused on making the Discord notification work, I could not even see this one ! Thanks again !