In my project I have a service class (_ServerPushService_) for handling PUSH notifications with following methods:
/** @var ServerPushMessage|null */
protected $message = null;
/**
* @param $message
* @return $this
*/
public function setMessage($message)
{
$this->message = $message;
return $this;
}
/**
* @param array|null $devices
* @return $this
*/
public function sendAndroid(array $devices = null) { ... }
I'm using Laravel Notifications (which implement _ShouldQueue_ and use _Queueable_) and the custom Channel for them. In the Channel class (_ServerPushChannel_) I call methods of the service above like:
$this->pushService->setMessage($message)
->sendAndroid($androidDevices);
$message is always a ServerPushMessage instance and $androidDevices is always an array. Notification is fired while scheduled console command is executed.
And it works perfectly on:
... but I doesn't work on:
It throws:
Symfony\Component\Debug\Exception\FatalThrowableError __clone method called on non-object
vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php:57 Illuminate\Notifications\ChannelManager::sendNow
vendor/laravel/framework/src/Illuminate/Notifications/SendQueuedNotifications.php:57 Illuminate\Notifications\SendQueuedNotifications::handle
[internal] call_user_func_array
vendor/laravel/framework/src/Illuminate/Container/Container.php:508 Illuminate\Container\Container::call
vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:94 Illuminate\Bus\Dispatcher::Illuminate\Bus\{closure}
vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104 Illuminate\Pipeline\Pipeline::then
vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:98 Illuminate\Bus\Dispatcher::dispatchNow
vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:47 Illuminate\Queue\CallQueuedHandler::call
vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:73 Illuminate\Queue\Jobs\Job::fire
vendor/laravel/framework/src/Illuminate/Queue/Worker.php:203 Illuminate\Queue\Worker::process
vendor/laravel/framework/src/Illuminate/Queue/Worker.php:153 Illuminate\Queue\Worker::runNextJob
vendor/laravel/framework/src/Illuminate/Queue/Worker.php:75 Illuminate\Queue\Worker::daemon
vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:100 Illuminate\Queue\Console\WorkCommand::runWorker
vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:84 Illuminate\Queue\Console\WorkCommand::fire
[internal] call_user_func_array
vendor/laravel/framework/src/Illuminate/Container/Container.php:508 Illuminate\Container\Container::call
vendor/laravel/framework/src/Illuminate/Console/Command.php:169 Illuminate\Console\Command::execute
vendor/symfony/console/Command/Command.php:261 Symfony\Component\Console\Command\Command::run
vendor/laravel/framework/src/Illuminate/Console/Command.php:155 Illuminate\Console\Command::run
vendor/symfony/console/Application.php:817 Symfony\Component\Console\Application::doRunCommand
vendor/symfony/console/Application.php:185 Symfony\Component\Console\Application::doRun
vendor/symfony/console/Application.php:116 Symfony\Component\Console\Application::run
vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:121 Illuminate\Foundation\Console\Kernel::handle
artisan:35 [main]
Everything works perfectly when I turn off queues on my production server. The PHP version is identical on both servers.
_Thanks in advance (and sorry for my bad english)._
While sending notifications to multiple notifiers Laravel clones the notification instance and sends a clone separately to each notifiable, the error shown here indicates that the notification instance sent is not an object, the issue doesn't have enough information for me to understand what's going on so you'll need to dig that yourself :)
Going to close the issue since it's not actually a bug, I suggest that you post on the forums and include the full code starting with how you send the notification, the notification channel, and the notification class, that way you can get help.