[3.0] Stop the buddy and ignore lists erroring when they are empty - #9406
Open
albertlast wants to merge 1 commit into
Open
[3.0] Stop the buddy and ignore lists erroring when they are empty#9406albertlast wants to merge 1 commit into
albertlast wants to merge 1 commit into
Conversation
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>
Closed
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
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:
BuddyIgnoreLists::buddies()runs its query unconditionally: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: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/$ignoredas the empty arrays the rest of each method already copes with —count()forbuddy_count, then aforeachthat 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_errorsgains 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