[3.0] Exclude the post groups already loaded by ID, not by post count - #9414
Merged
Sesquipedalian merged 2 commits intoAug 14, 2026
Merged
Conversation
getPostGroups() collects the post groups it already has as
self::$post_groups[$group->id] = $group->min_posts;
then hands that array straight to the query that fetches the rest:
WHERE id_group NOT IN ({array_int:known_post_groups})
{array_int:} takes the values, so id_group is compared against post counts
rather than group IDs. Two consequences: the groups that were already loaded
are not actually excluded, so they come back and are added a second time, and
any post group whose ID happens to equal another post group's min_posts is
excluded when it should not be, so it drops out of the list entirely.
The second one costs a group. With a custom post group at ID 9 requiring 4
posts already loaded, the query is asked for everything except ID 4, and
Newbie - the group for members with no posts - never arrives:
NOT IN (9) -> 4,5,6,7,8 the IDs, what the query means
NOT IN (4) -> 5,6,7,8,9 the post counts, what it passes
Signed-off-by: Mathias Papenbrock <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Sesquipedalian
requested changes
Aug 14, 2026
Sesquipedalian
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Group::getPostGroups()collects the post groups it already has in memory:then hands that array straight to the query that fetches the rest:
{array_int:}takes the array's values, soid_groupis compared against post counts instead of group IDs.Two consequences. The groups that were already loaded are not excluded, so they come back from the query and get written into the list a second time — harmless. And any post group whose ID happens to equal another post group's
min_postsis excluded when it should not be, so it drops out of the list entirely.The second one costs a group. Say a forum has a custom post group at ID 9 requiring 4 posts, and it is the one already loaded. The exclusion list becomes
[4]instead of[9], so the query is asked for everything except ID 4 — and Newbie, the group for members with no posts, never arrives. Run against the two lists on a forum with that group added:array_keys()is the fix.What I did not verify
I have not produced a member ending up in the wrong group through the UI. It needs a specific arrangement — a post group loaded whose
min_postscollides with another post group's ID — and I did not stage one end to end. The defect in the query is plain from the two lines that build the array, and the fix does not change behaviour in any other case: with default groups the current code excludes nothing (no group has ID 0, 50, 100, 250 or 500), so the only difference is that duplicates stop being re-fetched.Found while chasing an unrelated 500 through
User::saveBatch(), which is one of this method's callers.Issues References (Fixes|Related|Closes)
Related to #7933