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

(Fix) Missing parameter user in subforum #3265

Merged
merged 3 commits into from
Nov 26, 2023
Merged

(Fix) Missing parameter user in subforum #3265

merged 3 commits into from
Nov 26, 2023

Conversation

LostRager
Copy link
Contributor

No description provided.

@Roardom
Copy link
Collaborator

Roardom commented Nov 23, 2023

Probably would be a better idea to try and figure out why that variable is null instead of working around the error.

@Roardom
Copy link
Collaborator

Roardom commented Nov 23, 2023

Do you have it eager loaded on

and
->with('user', 'user.group', 'latestPoster', 'forum:id,name')
?

If so, perhaps the last_post_user_id field is empty on your forum, or belongs to a user that no longer exists. In which case that issue should be fixed instead.

@LostRager
Copy link
Contributor Author

Do you have it eager loaded on

and

->with('user', 'user.group', 'latestPoster', 'forum:id,name')

?
If so, perhaps the last_post_user_id field is empty on your forum, or belongs to a user that no longer exists. In which case that issue should be fixed instead.

Yes both are there.

Reverted change and tested again with ?? 0 to find the offending part. Its a user that got pruned. When i click into a topic the person links to system and when i click into post its listed as system. So that seems to work correctly.

Just forum index that has the issue.

@Roardom
Copy link
Collaborator

Roardom commented Nov 24, 2023

Ah, if it's a pruned user, the solution is the following:

Change

->with(['lastestPoster'])

into

->with(['lastestPoster' => fn ($query) => $query->withTrashed()])

@LostRager
Copy link
Contributor Author

LostRager commented Nov 24, 2023

Ah, if it's a pruned user, the solution is the following:

Change

->with(['lastestPoster'])

into

->with(['lastestPoster' => fn ($query) => $query->withTrashed()])

hmm, changing it in the SubscribedForum.php did not work,
but changing it in the ForumController.php, did work.
'forums.latestPoster' => fn ($query) => $query->withTrashed(),

Its linking to the user, so its the same result as using last_post_user_username so not quite sure what the benefit would be?

@Roardom
Copy link
Collaborator

Roardom commented Nov 24, 2023

The benefit is being able to remove :username to change all user routes to use the id instead of the username:

Route::prefix('users/{user:username}')->name('users.')->middleware(['auth', 'banned'])->scopeBindings()->group(function (): void {

@LostRager
Copy link
Contributor Author

The benefit is being able to remove :username to change all user routes to use the id instead of the username:

Route::prefix('users/{user:username}')->name('users.')->middleware(['auth', 'banned'])->scopeBindings()->group(function (): void {

Ahh that makes sense, thanks for explaining.

@HDVinnie HDVinnie merged commit a36f549 into HDInnovations:7.x.x Nov 26, 2023
4 checks passed
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.

None yet

3 participants