Skip to content

DeleteExpiredNotificationTokens: Call to a member function target() on null #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3likayed opened this issue May 2, 2025 · 4 comments

Comments

@3likayed
Copy link

3likayed commented May 2, 2025

For the given example for deleting tokens related to failed notifications i get Call to a member function target() on null

class DeleteExpiredNotificationTokens
{
    /**
     * Handle the event.
     */
    public function handle(NotificationFailed $event): void
    {
        $report = Arr::get($event->data, 'report');

        $target = $report->target(); // here $report is null

        $event->notifiable->devices()
            ->where('fcm_token', $target->value())
            ->update([
                'fcm_token' => null,
            ]);
    }
}

the notifications are queued and the queue is utilized with horizon

this happened after composer update for my project
here is my composer.json file

{
  "name": "laravel/laravel",
  "type": "project",
  "description": "The skeleton application for the Laravel framework.",
  "keywords": [
    "laravel",
    "framework"
  ],
  "license": "MIT",
  "require": {
    "php": ">=8.3",
    "ext-gd": "*",
    "ext-iconv": "*",
    "ext-simplexml": "*",
    "ext-xml": "*",
    "ext-xmlreader": "*",
    "ext-zip": "*",
    "ext-zlib": "*",
    "google/apiclient": "^2.16",
    "guzzlehttp/guzzle": "^7.8",
    "inertiajs/inertia-laravel": "^2.0",
    "irazasyed/telegram-bot-sdk": "^3.14",
    "james-heinrich/getid3": "^1.9",
    "laravel-notification-channels/fcm": "^5.1",
    "laravel/cashier": "^15.6",
    "laravel/framework": "^12.0",
    "laravel/horizon": "^5.3",
    "laravel/pulse": "^1.4",
    "laravel/sanctum": "^4.0",
    "laravel/tinker": "^2.10",
    "league/flysystem-aws-s3-v3": "3.0",
    "maatwebsite/excel": "^3.1",
    "owen-it/laravel-auditing": "^14.0",
    "pbmedia/laravel-ffmpeg": "^8.5",
    "php-ffmpeg/php-ffmpeg": "^1.2",
    "phpoffice/phpword": "^1.3",
    "pion/laravel-chunk-upload": "^1.5.6",
    "predis/predis": "^2.3",
    "reedware/laravel-relation-joins": "^8.0",
    "spatie/laravel-medialibrary": "^11.4",
    "spatie/laravel-permission": "^6.4",
    "spatie/laravel-query-builder": "^6.3",
    "stancl/tenancy": "^3.8",
    "staudenmeir/belongs-to-through": "^2.15",
    "staudenmeir/eloquent-has-many-deep": "^1.19",
    "stevebauman/location": "^7.3",
    "tightenco/ziggy": "^2.1",
    "timacdonald/pulse-validation-errors": "^1.5"
  },
  "require-dev": {
    "barryvdh/laravel-debugbar": "^3.9",
    "fakerphp/faker": "^1.9.1",
    "kitloong/laravel-migrations-generator": "^7.0",
    "laravel/pint": "^1.0",
    "laravel/sail": "^1.41",
    "laravel/telescope": "^5.0",
    "mockery/mockery": "^1.4.4",
    "nunomaduro/collision": "^8.1",
    "phpstan/phpstan": "^1.11",
    "phpunit/phpunit": "^11.1",
    "reliese/laravel": "^1.2",
    "spatie/laravel-ignition": "^2.9"
  },
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "Database\\Factories\\": "database/factories/",
      "Database\\Seeders\\": "database/seeders/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    },
    "files": [
      "app/Helpers/helper.php"
    ]
  },
  "scripts": {
    "post-autoload-dump": [
      "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
      "@php artisan package:discover --ansi"
    ],
    "post-update-cmd": [
      "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
    ],
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@php artisan key:generate --ansi"
    ]
  },
  "extra": {
    "laravel": {
      "dont-discover": [
      ]
    }
  },
  "config": {
    "platform-check": false,
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true,
    "allow-plugins": {
      "pestphp/pest-plugin": true,
      "php-http/discovery": true
    }
  },
  "minimum-stability": "dev",
  "prefer-stable": true
}
@dwightwatson
Copy link
Collaborator

Can you please determine what packages actually changed when you ran composer update and see if you can narrow down specifically what change led to the error occurring?

@3likayed
Copy link
Author

3likayed commented May 4, 2025

Can you please determine what packages actually changed when you ran composer update and see if you can narrow down specifically what change led to the error occurring?

I've introduced a model called App/Models/Report
may that lead to this issue ?

@dwightwatson

@dwightwatson
Copy link
Collaborator

No, it would be related to something that changed in your Composer dependencies.

@3likayed
Copy link
Author

3likayed commented May 4, 2025

these are the composer changes

"spatie/laravel-ignition": "^2.9",
"laravel/sail": "^1.41", //upgraded from  "laravel/sail": "^1.18"
"league/flysystem-aws-s3-v3": "3.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants