Skip to content
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

Laravel Telescope errors when creating user via the make:user command #10525

Closed
rrelmy opened this issue Jul 29, 2024 · 0 comments · Fixed by #10586
Closed

Laravel Telescope errors when creating user via the make:user command #10525

rrelmy opened this issue Jul 29, 2024 · 0 comments · Fixed by #10586
Labels

Comments

@rrelmy
Copy link
Contributor

rrelmy commented Jul 29, 2024

Bug description

When accessing User::editUrl directly or through other methods like User::toArray before the model has been persisted results in a UrlGenerationException. This is expected as the urls required the ID.
This breaks the creation of users.

We initially discovered this issue by installing Laravel Telescope which records all events by default and tries to serialise the model in the UserCreating event.

Not sure if this is something you want to fix, I mainly want to document it for other users any my future self. 😅

Workaround when using telescope

Add the events to the ignore list in config/telescope.php

        Watchers\EventWatcher::class => [
            'enabled' => env('TELESCOPE_EVENT_WATCHER', true),
            'ignore' => [
                \Statamic\Events\UserCreating::class,
                \Statamic\Events\UserSaving::class,
            ],
        ],

How to reproduce

  1. Add a listener to the UserCreating event
        Event::listen(UserCreating::class, function (UserCreating $event) {
            dump($event->user->toArray());
        });
  1. Create a user with php please make:user

Alternatively you can install Laravel Telescope and enable it

Logs

Illuminate\Routing\Exceptions\UrlGenerationException 

  Missing required parameter for [Route: statamic.cp.users.edit] [URI: cp/users/{user}/edit] [Missing parameter: user].

  at vendor/laravel/framework/src/Illuminate/Routing/Exceptions/UrlGenerationException.php:35

Environment

Environment
Application Name: Statamic
Laravel Version: 11.17.0
PHP Version: 8.3.9
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: localhost

Statamic
Addons: 3
Sites: 1
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.17.0 PRO

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

@duncanmcclean duncanmcclean changed the title UserCreating and UserSaving (for new) events break with Telescope or when accessing user data $user->toArray() errors when accessed in UserCreating/UserSaving event listeners Aug 7, 2024
@duncanmcclean duncanmcclean changed the title $user->toArray() errors when accessed in UserCreating/UserSaving event listeners $user->toArray() errors when accessed in UserCreating/UserSaving event listeners with Laravel Telescope installed Aug 7, 2024
@duncanmcclean duncanmcclean changed the title $user->toArray() errors when accessed in UserCreating/UserSaving event listeners with Laravel Telescope installed Laravel Telescope errors when creating user via the make:user command Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants