[3.0] Replace count_posts (where 0 = true) with posts_count (where 1 = true) - #9517
[3.0] Replace count_posts (where 0 = true) with posts_count (where 1 = true)#9517Sesquipedalian wants to merge 4 commits into
Conversation
Doesn't do anything yet, but it will soon. Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
ff265f5 to
65b9849
Compare
|
I have tested this on both engines, and the diagnosis and the fix are right. I reproduced #9415 on On this branch the same driver is 16/16 on MySQL and on PostgreSQL, both from a fresh install and after the upgrader. I then swept the areas around it over real HTTP rather than trusting the grep: the admin board form round trip, creating a board, the board report, On whether you got all of them: yes, for SMF's own code. Nothing outside the deliberate compatibility code and Four things I do not think hold up, though. 1.
|
| * Whether posts in this board count toward a user's total post count. | ||
| */ | ||
| public bool $count_posts = true; | ||
| public bool $posts_count = true; |
There was a problem hiding this comment.
Any reason we shouldn't include a property hook for legacy calls?
public bool $count_posts{
get {
return !$this->posts_count;
}
}
}
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
6a143a4 to
a3a0fa2
Compare
|
Retested at a3a0fa2, on both engines, and also against a real 2.1 forum this time — the committed SMF 2.1.7 baseline from #9330, 403 members and 6 000 messages across 24 boards, restored and then upgraded. Four of the five things I raised are fixed. There is one new problem that stops the branch running at all, and one regression in the alias path. The branch does not boot:
|
Fixes #9415
As explained here, the
count_postscolumn of the boards table uses 0 for true and 1 for false, and it has been doing this since way back in SMF 1.0.This is insane.
Code that was newly written for SMF 3.0 has been built on the reasonable assumption that 1 means true and 0 means false, whereas old code that was ported over from SMF 2.1 without significant changes still assumes that
count_postsuses 0 for true and 1 for false. This inconsistency is what ultimately caused #9415, because it created inconsistent handling of member's post counts.Rather than patching the new code in order to perpetuate the madness, I have instead decided to fix all the old code in order to end this lunacy once and for all.
In order to avoid confusion in the mind of any developer looking at this code in the future, I have decided to completely replace the old
count_postscolumn with a newposts_countcolumn that uses sane logic. This change means that all existing installs of SMF 3.0 will need be upgraded by running the upgrader after this PR has been merged.In order to maintain backward compatibility with any old mods that expected the old
count_postscolumn and its inverted logic, I have also added some code to the database API classes that transparently replaces any references to the oldcount_postscolumn in query strings with references to the newposts_countcolumn.