Skip to content

[3.0] Stop the buddy and ignore lists erroring when they are empty - #9406

Merged
Sesquipedalian merged 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/buddy-ignore-empty-lists
Aug 14, 2026
Merged

[3.0] Stop the buddy and ignore lists erroring when they are empty#9406
Sesquipedalian merged 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/buddy-ignore-empty-lists

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Profile → Buddies and Ignore List is an error page for any member who has not added a buddy — which is every member on a new forum:

Database error, given array of integer values is empty. (buddy_list)
Function: retrieveUserData

BuddyIgnoreLists::buddies() runs its query unconditionally:

$buddies = User::loadCustom(
	[
		'where' => ['mem.id_member IN ({array_int:buddy_list})'],
		'limit' => \count(Profile::$member->buddies),
		'params' => ['buddy_list' => Profile::$member->buddies],
	],
	UserDataset::Profile,
);

An empty array in {array_int:} is a hard database error in SMF's query layer, not a query that matches nothing. ignore() has the same shape and the same problem.

2.1 had the guard — Sources/Profile-Modify.php:

if (!empty($buddiesArray))
{
	$result = $smcFunc['db_query']('', '
		SELECT id_member
		FROM {db_prefix}members
		WHERE id_member IN ({array_int:buddy_list})
	…

It was lost when this moved to User::loadCustom(). Both lists now skip the query when there is nothing to look up, which leaves $buddies / $ignored as the empty arrays the rest of each method already copes with — count() for buddy_count, then a foreach that does not run.

Checked

On the running forum, as an admin with no buddies and nobody ignored. Before: both pages render the error, and smf_log_errors gains a row per visit. After: both render their "Add to buddy list" / "Add to ignore list" forms, and nothing is logged.

Found while sweeping every page of a stock forum for fatals, alongside #9405.

Issues References (Fixes|Related|Closes)

Related to #7933

Both pages ran their member query unconditionally:

  'where' => ['mem.id_member IN ({array_int:buddy_list})'],
  'params' => ['buddy_list' => Profile::$member->buddies],

An empty array in {array_int:} is a database error in SMF's query layer, not
a query that matches nothing, so a member who has never added a buddy got
"Database error, given array of integer values is empty. (buddy_list)" and an
error page where the list should be. Same for the ignore list. That is every
member on a new forum, and the error log fills up with it.

2.1 wrapped the equivalent query in if (!empty($buddiesArray)); the guard was
lost when this moved to User::loadCustom(). Both lists now skip the query
when there is nothing to look up, which leaves $buddies and $ignored as the
empty arrays the rest of each method already handles.

Signed-off-by: Mathias Papenbrock <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@albertlast albertlast mentioned this pull request Aug 8, 2026
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 6 milestone Aug 8, 2026
Comment thread Sources/Actions/Profile/BuddyIgnoreLists.php Outdated
Comment thread Sources/Actions/Profile/BuddyIgnoreLists.php Outdated
Co-authored-by: Jon Stovell <jonstovell@gmail.com>
@Sesquipedalian
Sesquipedalian merged commit 55834e3 into SimpleMachines:release-3.0 Aug 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants