[3.0] Replace count_posts (where 0 = true) with posts_count (where 1 = true) - #9517
Conversation
Doesn't do anything yet, but it will soon. 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.
|
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:
|
|
The latest commits resolve the flagged issues apart from the migration not being able to run on PostgreSQL. They also add fixes for #9518. |
|
Retested at 6a8a22a. All three blockers are gone, and the three post-count fixes on top hold up under testing. Details below, then three things that are still open. I tested this branch with #9522 cherry-picked on top, since that was the last remaining failure in my sweep.
The three fixes on topI checked these rather than taking the commit messages for it, and all three are genuinely fixed rather than moved: Quick moderation now decrements. Separating the accumulator from the The Reading The recount, at a size worth the name: after a full paginated run over the baseline's 403 members (two continuation rounds), not one member disagrees with the messages that ought to count. The And the migration still lands correctly on real 2.1 data: the two boards I set to Still open1. The PostgreSQL temp table in The column type is fixed, but the part PostgreSQL rejects is the shape rather than the types — there is no
2. A mod's own column is now caught when a boards table is in the same query. The optional alias group matches the empty string, so the pattern also fires inside a different qualifier, while Replacing the leading 3. A rewritten
Everything else I raised is fixed. #9522 is right too — For completeness on how the upgrade run was done: the 2.1 → 3.0 upgrade needs the two |
1927f4b to
ef60032
Compare
|
The three remaining issues, "The PostgreSQL temp table in recountPosts() still fails," "A mod's own column is now caught when a boards table is in the same query," and "A rewritten SELECT list still loses the old name" should now all be fixed. |
5a9b4a6 to
c612c99
Compare
|
Retested at c612c99, with Everything I raised is now fixed. The
The shim checks now go past the rewritten string to the rows themselves: an old mod's I also pushed on that new One thing still outstandingThe PostgreSQL temp table in PostgreSQL's CREATE TEMPORARY TABLE t (id_member) AS SELECT …
CREATE TEMPORARY TABLE t AS SELECT … ; ALTER TABLE t ADD PRIMARY KEY (id_member);The consequence is real rather than cosmetic. Setting every board to not count posts and leaving a member holding
That is item 4 of #9518, which this pull request is set to close. Everything else about the branch looks right to me. With #9524 in flight for the schema layer, the upgrade path this migration needs on PostgreSQL should open up too — I will retest that against #9524 separately. |
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
c612c99 to
0aa4ad1
Compare
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
ecd84e3 to
d3ad5df
Compare
|
Retested at d3ad5df with current The one thing still outstanding is fixed. The recount cleanup step now runs on PostgreSQL: Verified twice over: once by replaying the step exactly as
(While looking: The Everything else still passes
The wide sweep was run with the shim on as well as off on both engines this time. One suggestion, not a defectThe temporary table has no Both engines. Not this pull requestOne error appears in the PostgreSQL log during the sweep:
Looks good to me. |
|
Following up on the temporary table point from my last comment, because "add The problem, first. Both engines.
But it makes the bug quieter rather than fixing it. So the second recount would decide who has a stale post count by consulting the first recount's answer. That is worse than the current behaviour, which at least does nothing.
Two things to avoid on the way there:
|
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Fixes #9415
Fixes #9518
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.