[3.0] Makes the settings counters increment on PostgreSQL too - #9340
Merged
jdarwood007 merged 1 commit intoAug 2, 2026
Merged
Conversation
updateModSettings($x, true) emits SET value = value + 1 against settings.value, which is a text column. MySQL coerces that silently; PostgreSQL rejects it with "operator does not exist: text + integer", and since the PostgreSQL API discards failed queries without a word, the statement simply did nothing. So on PostgreSQL every counter that goes through this path - totalMessages, totalTopics, totalMembers, unapprovedMembers - has been frozen at whatever value the last full recount produced. This install had totalMessages stuck at 4 with 5 messages in the table. Casting into DECIMAL and back out through CONCAT() keeps the increment a single atomic statement and is accepted by both databases. 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
Config::updateModSettings($array, true)supportstrueandfalseas values, meaning "increment" and "decrement". It builds this:settings.valueis a text column. MySQL coerces it and the counter goes up. PostgreSQL refuses:Nothing then happens. The PostgreSQL API discards failed statements without logging or raising (see #9341), so the query simply does nothing and the request carries on. Four counters go through this path —
totalMessages,totalTopics,totalMembersandunapprovedMembers— and on PostgreSQL none of them have been moving. They only ever look right after a manual recount in Forum Maintenance, until the next post pushes them out of step again.Easy to see on a PostgreSQL install:
Casting into
DECIMALand back out throughCONCAT()is accepted by both databases and keeps the increment a single atomic statement, so two simultaneous posts still cannot lose a count:Testing
Docker environment, PostgreSQL 17. Before the change, posting a reply left
totalMessagesat 4 with 5 rows insmf_messages. After it, each new post moves the counter, a new topic movestotalTopics, and Forum Maintenance → recount agrees with the live totals (7 and 7).Verified the expression on both engines directly:
vendor/bin/phpunit— 108 tests, 157 assertions, OK.Issues References (Fixes|Related|Closes)
Related to #9341