[2.1] Calls db_fetch_row() when counting the smileys - #9684
Open
albertlast wants to merge 1 commit into
Open
albertlast wants to merge 1 commit into
albertlast wants to merge 1 commit into
Conversation
list_getNumSmileys() named the callable without invoking it, so list() destructured the function name itself. The count was always null, which leaves the edit-smileys list with no page index, and PHP 8.5 warns "Cannot use string as array" every time the page is built. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
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
list_getNumSmileys()names the callable but never invokes it:so
list()destructures the string'smf_db_fetch_row'rather than a result row. Two consequences:null.createList()puts that in$list_context['total_num_items'], and thetotal_num_items > items_per_pagetest inSubs-List.phpcan then never pass, so the edit-smileys list never gets a page index. A forum with more than 40 smileys can only ever see the first 40.Warning: Cannot use string as arrayis new in 8.5; PHP 7.4 through 8.4 assignnullsilently, which is why this has gone unnoticed. Confirmed by running the same statement under 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 (all silent) and 8.5 (warns).The fix is to call it, matching the sibling count callbacks such as
list_getNumBans()inManageBans.php.The query result was already being freed correctly, and
$numSmileysis returned as-is, the same way the other count callbacks return theirs.SMF 3.0 is not affected: the callback was rewritten as
SMF\Actions\Admin\Smileys::list_getNumSmileys()and callsDb::$db->fetch_row($request)properly. A grep of 3.0'sSources/forfetch_rowused without a call finds nothing else.Issues References (Fixes|Related|Closes)
Reported on the community forum against 2.1.7, where the admin saw the warning in the error log after adding a smiley. The animated GIF and the language pack mentioned in that report are incidental: the query is
SELECT COUNT(*) FROM {db_prefix}smileysand the warning fires on every load ofaction=admin;area=smileys;sa=editsmileys.🤖 Generated with Claude Code