clockwork icon indicating copy to clipboard operation
clockwork copied to clipboard

ErrorException Attempt to read property "subject" on null LaravelNotificationsDataSource.php:177

Open faraweilyas opened this issue 2 years ago • 3 comments
trafficstars

I have this code below that I use to send multiple notifications to agents which works fine without clockwork being enabled but as soon as I enable clockwork the code fails with this error ErrorException Attempt to read property "subject" on null LaravelNotificationsDataSource.php:177

I'm not sending email notification, it's a database notification.

$cardTrade  = App\Models\CardTrade::with(['card_code.card', 'handler', 'submitted_by', 'history'])
                    ->findOrFail($card_trade_id);

 $amount = $cardTrade->getProcessedAmount();

    $agents = App\Models\User::where('account_type', 'AG')->get();

 Illuminate\Support\Facades\Notification::send($agents, new App\Notifications\TradeAction(
        "IncomingNewCardTrade",
        "User requested to trade {$amount->formatted} {$cardTrade->getCardName()} card.",
        $cardTrade
    ));

faraweilyas avatar Dec 16 '22 15:12 faraweilyas

having the same issue as well

Abdelraman avatar Feb 16 '23 10:02 Abdelraman

Have a very similar issue. The issue seems to be an assumption that defining a toMail method on the notification is reason enough to run that method. Some notifications may be used for different notifiable's that don't support every method.

The correct way that this should work is in resolveChannelSpecific to inspect the incoming $event which has a 'channel' property - rather than using the method existence.

This bug is impactful enough that we won't be able to use Clockwork unfortunately.

jameshulse avatar Jun 19 '23 03:06 jameshulse

This is now fixed in master and will be released soon, thanks for the suggestion @jameshulse.

itsgoingd avatar Jun 25 '23 22:06 itsgoingd

Well, when I've said soon, I've lied. :) But this is finally fixed in Clockwork 5.2.

itsgoingd avatar Feb 21 '24 20:02 itsgoingd