-
Notifications
You must be signed in to change notification settings - Fork 845
explode issue using Jetstream with PHP 8.1 #1121
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
Comments
The users' name is not If you have changed this in your own application you should consider handing this in your application. Likely more of Jetstream is also in a bad state if the users name is also allowed to be |
I have built my own profile photo implementation as I would prefer to avoid editing vendor code unless intended. I ran into the error in my app and shared my findings to save someone else the hours of research it took me to figure out. If you intend to say that there is a better place to share this information specific to code I believed was meant to be used as-is, then I'm happy to be pointed in that direction. On the other hand, I'm fine considering it moot since I've found a solution for my own project. I appreciate you taking the time to review the information. |
Right now, the user's name is required as @timacdonald explained. If you want to change this you can maybe attempt a PR. Sorry |
My post has nothing to do with the user's name. After registration the user's profile photo path is not set. Visiting the profile page call's the explode function via defaultProfilePhotoUrl() function on the HasProfilePhoto Trait. At this point no profile photo has been set so the value coming from the DB is null. I have provided as much info as is needed to recreate the issue and the solution that worked for my project. Like I stated before I only intended to save the people who would run into the error like I did some research time. I appreciate the exchange of ideas, but this has taken more of my time than I intended. Hope the info helped\helps someone, Or it can be deleted if decided that it's irrelevant. |
Description:
Disclaimer: I'm sharing not complaining... ;)
line 74 on the HasProfilePhoto trait throws an error related to the explode function on php 8.1
LOG.warning: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/html/vendor/laravel/jetstream/src/HasProfilePhoto.php on line 74
Fix
change
explode(' ', $this->name)
to
explode(' ', $this->name ?? '')
note: Since this vale comes from the DB it can sometimes be null which is deprecated for explode in PHP 8.1. Passing an empty string instead of null seems to work.
Hope this helps.
Steps To Reproduce:
When using Jetstream + HasProfilePhoto Trait on PHP 8.1 and no profile image has been assigned to the user.
The text was updated successfully, but these errors were encountered: