I think I found the issue. Searched the logs for your user ID and found memory errors for the last few days (prior, you had the duplicate issue).
The problem appears to be that for every game in the favorites list, Laravel is loading every user who favorited that game and every user who is restricted from it. If just one popular game has 1,000+ favorites, that’s 1,000+ User models in memory. So, when it exceeds memory, it’s crashing.
I’m trying to get the code fixed right now. May take a couple of tries before I get it. Like I’ve said before, I’m not a dev. But I’m fairly good at muddling my way through code to make it do what I want… eventually.
I’ll post up here when I’m ready for you to try it again. If anyone sees issues with their favorites today, please be patient. I want to get it fixed, but may break things in the process.
Not sure why it was done this way. I didn’t like that you could duplicate favorites, either (there were thousands of these in the db). I had never paid attention to the structure before I found that problem, but have fixed it in the db by adding a unique key on user.id + game.id.
For this? I’m not sure. I’m trying to pick through the code with chatgpt’s help, but keep having to correct it on how the code is structured and why it is that way (it was trying to remove chunks of code that break the whole program).
The offending function appears to be this:
public function favorites(): View
{
$user = Auth::user();
$games = Game::with(['usersWithFavorite', 'usersRestrictedAccess'])
->whereRelation('usersWithFavorite', 'user_id', '=', $user->id)
->where(function (Builder $query) use ($user) {
$query->doesntHave('usersRestrictedAccess')
->orWhereHas('usersRestrictedAccess', function (Builder $query) use ($user) {
$query->where('user_game_restricted_access.user_id', '=', $user->id)
->orWhere('game.user_id', '=', $user->id);
});
})
->orderBy('title', 'asc') // Sorting by the 'title' column in ascending order
->paginate(10);
return view('games.favorites', compact('games', 'user'));
}
Huh. I’d have guessed from the look of it that it would just build a SQL query, and a database server that can’t handle large database tables isn’t a very good database server…
It’s not really SQL having the issue, it’s PHP getting stuck in a loop and throwing PHP memory errors. I mean, I could bump up the memory allocated for it, but I think the problem will just happen again unless I fix the root cause. From the laravel logs…
[2025-07-06 07:15:13] local.ERROR: Allowed memory size of 31457280 bytes exhausted (tried to allocate 20480 bytes) {“userId”:xxxx,“exception”:"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Allowed memory size of 31457280 bytes exhausted (tried to allocate 20480 bytes) at /var/www/cogdemos/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:2299)
@Big_fan1231 When you get a chance, try your favorites again. I made a small change to the function that might fix the problem. I still haven’t been able to duplicate it on my end, but I found a user with 402 favorites, so I am going to copy that to one of my test logins and see what happens.
Yeah, so obviously that function does something else than what I’d have guessed, because if it did what I guessed then PHP would have no reason to choke.
Well, I copied all of the favorites from the user who had 402 games favorited (@MattisHell333, I’m assuming you got a 500 error on your favorites??) and could access them with no issues. They are paginated (40 pages worth). I clicked through them and had no issues.
Hopefully, this fixed everyone’s 500 error for their favorites. I’ll wait to hear back from people. If it works, I’ll push this change up.
hi anyone has a problem for save game ? me i can’t. its said storage full, delete olders saves or free up before try again. i 've also this problem with many games. it’s the first time i 've this problem. thanks for your help !
Is this for local saves? Are you on a mobile device?
Unfortunately, it looks like I’m going to need to alter the code to limit the number of local saves people can have per game, similar to how server-side saves are done. It will mean people will need to export their saves more often, but it should solve this storage error people are getting. I’ve never seen it on my end, but I tend to play on my laptop, rather than on a mobile device (mainly because the print is too small for me and, if I make it large enough, there are like three words before I have to scroll, lol).
I think even if we use indexedDB, we’d end up with this issue on mobile. The saves aren’t very large, but I think some devices are having issues. Not sure if I can make the limit device-based or not. Going to tinker with it and, if I hit a dead end, I’ll get the dev to deal with it.
I’m not sure about Android, but iOS has a fixed amount of storage space allocated to browser cache files (although in my experience, it just frees up space by deleting the old ones), while on a computer you can change it, so yeah, you wouldn’t see it on a computer unless you have a limit and are running low on space.