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

Control panel breaks when avatar is added to logged in user #11364

Closed
patrosk opened this issue Jan 17, 2025 · 6 comments
Closed

Control panel breaks when avatar is added to logged in user #11364

patrosk opened this issue Jan 17, 2025 · 6 comments

Comments

@patrosk
Copy link

patrosk commented Jan 17, 2025

Bug description

I've encountered a strange problem that breaks the control panel. My users table has an avatar field and I've added an assets field to the UserBlueprint where it is possible to upload or choose an image. I can add and remove avatars for users and they appear next to the user name in the Users section of the control panel, as expected. If I however add an avatar to the user with which I am currently logged in, after I've saved the changes, the control panel breaks and I get "This page isn't working - localhost didn't send any data". There are no other error messages, nothing in the console and the error logs in my project don't receive any new errors either. I've restarted everything, cleared cache and cookies, which logs the user out and I am presented with the login form. I can login with another user and see the avatar next to my user name, but if I login with a user that has an avatar the control panel breaks. If I remove the avatar from the database table, everything works normally again.

Remaining backend and frontend of the project works as it should. I can access the user avatars in my frontend (I'm displaying it next to the article author name). I've tried debugging by dumping in various files and functions - for example in the HasAvatar trait, where it seems to find the data it needs. I've also tried to empty the dashboard view completely, save for a simple p tag (thinking there was some issue with how the user data is fetched and presented on the dashboard), which changed nothing.

Since the avatars of users are displayed in the dashboard and are accessible in the frontend, I'm assuming that there is nothing wrong with how the data is saved and retrieved. But I'm at a total loss as to why the control panel breaks. Has anyone had a similar issue?

How to reproduce

  1. Set up a Laravel project with statamic
  2. Make sure the users table has an avatar column
  3. Configure the UserBlueprint so that it is possible to add an avatar to the user in the control panel
  4. Add an avatar to the logged in user

Logs

No response

Environment

Environment
Application Name: Laravel
Laravel Version: 10.48.13
PHP Version: 8.3.6
Composer Version: 2.7.2
Environment: local
Debug Mode: ENABLED
URL: localhost:8020
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / daily, flare
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 2
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.40.0 PRO

Statamic Addons
statamic/eloquent-driver: 4.18.0
tdwesten/statamic-builder: 1.0.12

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: eloquent
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: eloquent
Sites: file
Taxonomies: eloquent
Terms: eloquent
Tokens: file

Installation

Existing Laravel app

Additional details

I'm using tdwesten/statamic-builder for creating blueprints, collections etc. The frontend is a separate project.

@patrosk
Copy link
Author

patrosk commented Jan 17, 2025

Update: after more debugging and die dumping, I've found that the error seems to occur in the blueprint() function on the user (found in the UserRepository class in statamic/cms/src/Auth/UserRepository), namely in USerBlueprintFound::dispatch($blueprint). The dispatch function, located in statamic/cms/src/Events/Event.php, returns event($event), and it is here that it seems to break. If I comment out the return statement, I can access the control panel as before, even with my user that has an avatar. Everything looks and works like it should. When logging $event::class, almost 500 identical rows (local.DEBUG: Statamic\Events\AssetContainerBlueprintFound ) are printed to my logs file, which could indicate that the event is triggered too many times?

Image

@duncanmcclean
Copy link
Member

Do you see any errors in your log file when the CP breaks?

Can you try uninstalling tdwesten/statamic-builder to see if that makes a difference? It seems to be overriding quite a few classes in Statamic Core.

@patrosk
Copy link
Author

patrosk commented Jan 17, 2025

@duncanmcclean if I remove tdwesten/statamic-builder, the control panel is accessible again. The blueprints and collections are gone (since they were created with statamic-builder), and the avatar field on users is gone as well (since the UserBlueprint was also added with statamic-builder). I guess the issue has to do with some clash between the user blueprints from statamic and statamic-builder then?

And no, no errors appear in the log file when the control panel breaks.

@duncanmcclean
Copy link
Member

I guess the issue has to do with some clash between the user blueprints from statamic and statamic-builder then?

Yes, it might be best bringing it up with the addon developer. We don't typically recommend that addons re-bind internal Statamic classes.

@patrosk
Copy link
Author

patrosk commented Jan 17, 2025

Thanks for your replies @duncanmcclean !

@danielbrodin
Copy link

@duncanmcclean just to give an update. This wasn't because of statamic-builder, it's the bug that is trying to get fixed in #11390 between statamic and telescope that caused it.

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

No branches or pull requests

3 participants