[3.0] Pass logBan() its row in the structure insert() expects - #9312
Merged
live627 merged 1 commit intoJul 28, 2026
Merged
Conversation
Db::$db->insert() takes a multidimensional array, one entry per row, and rejects anything else: Invalid data structure sent to the database.<br>Function: logBan logBan() passed a single flat row. Forums running with $backward_compatibility enabled never noticed, because the database layer quietly wraps the row for them, but that is off by default, so on a new install every ban hit logged a critical error and the member got an error page instead of being told they were banned. Wraps the row so it is a list of rows, matching every other caller. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
live627
approved these changes
Jul 28, 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.
Note
This change was produced by an LLM. The code, the commit message and this
description were all written by Claude (Anthropic), driven by @albertlast. It has
not yet had human code review.
Everything stated below was verified by actually running it against a fresh
PostgreSQL install of this branch, rather than only reasoned about. Even so,
please review it as untrusted work: the diagnosis may be right while the fix is
not what SMF would prefer stylistically or architecturally.
Description
Db::$db->insert()takes a multidimensional array, one entry per row, and rejectsanything else:
Logging::logBan()passed a single flat row:[ $id ?? User::$me->id, $ip_address ?? User::$me->ip, $email ?? User::$me->email, time(), ],Forums running with
$backward_compatibilityenabled never notice, becauseSMF\Db\APIs\PostgreSQL::insert()(and the MySQL equivalent) quietly wrap the rowfor them. That setting is
0by default, so on a new install every ban hit logged acritical error, no row was written to
log_banned, the ban item hit counter neverincremented, and the member got an error page rather than the ban message.
This wraps the row so it is a list of rows, matching every other caller.
How this was verified
With a real
cannot_accessban in place, on PostgreSQL 17 / PHP 8.4:smf_log_bannedempty,smf_ban_items.hitsstayed0, one critical errorlogged per request.
smf_log_bannedrows with the correct IP,hitsincremented to3, and no errors logged.Relationship to other PRs
Only reachable once bans work, so best reviewed with #9310 and #9311. Merges cleanly
alongside both; they touch different files.
Issues References (Fixes|Related|Closes)