Skip to content

Telescope::afterStoring only calls first hooks #1665

@Uskrai

Description

@Uskrai

Telescope Version

5.15

Laravel Version

12.0

PHP Version

8.4.15

Database Driver & Version

No response

Description

Telescope::store invoke Telescope::$afterScoringHooks using Collections::every making it short-circuit if first hooks doesn't return true. is this intentional?

Steps To Reproduce

with default telescope config running this command will not call afterStoring callback

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Laravel\Telescope\Contracts\EntriesRepository;
use Laravel\Telescope\Telescope;

class TestTelescopeStore extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'test:telescope-store';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        DB::statement("
            CREATE TABLE IF NOT EXISTS test_store (
                id UUID PRIMARY KEY,
                updated_at TIMESTAMP NULL
            )
        ");

        DB::table("test_store")->insert([
            'id' => \Str::orderedUuid()->toString(),
            'updated_at' => now()
        ]);

        Telescope::afterStoring(function () {
            $this->info("after storing inside");
        });
        Telescope::store(app(EntriesRepository::class));
        $this->info("after storing outside");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions