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

[5.x] Prevent error when Laravel Telescope serializes a user before its created #10586

Conversation

duncanmcclean
Copy link
Member

This pull request fixes an issue where an error would occur when creating a new user, when the Laravel Telescope package is installed.

  • When a user is being created, it dispatches two events: UserCreating and UserSaving.
  • Laravel Telescope listens for any events being dispatched and attempts to serialize them using json_encode.
  • When the User object gets serialized, it'll end up augmenting the user via HasAugmentedInstance::jsonSerialize().
  • The AugmentedUser::commonKeys() array includes edit_url and api_url.
  • When the editUrl and apiUrl methods are called on the User, they error out due to no ID being set, since the user hasn't been created yet.
    • We do a similar "if no id, return null" check for editUrl and apiUrl in entries.
    • We don't do this check for things like taxonomies, because their URLs use slugs which exist on the object before the term is created.

Closes #10525.

@jasonvarga jasonvarga merged commit d0ad38c into 5.x Aug 7, 2024
18 checks passed
@jasonvarga jasonvarga deleted the prevent-error-when-telescope-serializes-a-user-before-its-created branch August 7, 2024 16:31
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

Successfully merging this pull request may close these issues.

Laravel Telescope errors when creating user via the make:user command
2 participants