Skip to content

Jetonomy 2.1.0 (re-tag) - #88

Merged
vapvarun merged 24 commits into
mainfrom
2.1.0
Nov 24, 2026
Merged

vapvarun merged 24 commits into
mainfrom
2.1.0

Conversation

@vapvarun

Copy link
Copy Markdown
Owner

Re-tag of 2.1.0 with the fixes found after the first tag: one display timezone for every stored time, rows-changed hooks for votes, flags, join requests, blocks and reactions, the linked-forum guard, access-rule refusal on forums that must stay public, and the changelog line for older import history.

…k, collapsed or open

On the Community page the sub-category chips sat directly against the category's own
space cards when collapsed (0px), and the cards were 12px under the open panel.
`.jt-cat-subs + * { margin-top }` was meant to space them, but `.jt-app .jt-space-grid
{ margin: 0 }` is heavier and later, so the grid's top margin was always 0; the 12px
under an open panel came from the panel itself.

The grid now has its own rule that outweighs the reset, and whatever else follows the
block takes the same step. The step is 16px, the same as the heading row above the
chips, inside the 12-16px the owner asked for. The RTL and minified files are
regenerated from the source with the project's Grunt tasks.

Measured on Reign 8.1.2 (light, dark, 1280 and 390): the grid's top margin and the gap
are 16px collapsed and expanded, on the Community page and on the category pages; before,
0px collapsed and 12px expanded.

Test: the rule is in the source and in both generated stylesheets; it fails on the old CSS.
…, not twice

Vote::cast() tested `false === $result` after Model::insert(), which returns int 0 on failure, so the
duplicate-key guard added in 0c33fdb could never run (PHPStan's baseline had even recorded the comparison as
always false): the losing request fell through, recomputed the score, fired jetonomy_vote_cast and, through
record(), jetonomy_after_vote and a second reputation award. Retracts and flips had the same shape:
Model::delete()/update() answer true even when no row changed, so two parallel retracts both took the
reputation back.

cast() now decides every write by the rows it changed: the insert by the unique key, the retract and the flip by
a delete or update conditional on the value that was read. A request that changed nothing answers a new
`unchanged` action; record() fires no hook and moves no reputation for it, and the REST vote routes do not count it
against the rate limit and report the state the member now has (created or removed, plus unchanged: true) so the
page shows the right button. The duplicate check also read last_error after ROLLBACK, which clears it; it is read first.

Flags had the same race (8 parallel reports left 7 rows, each docking the author): Flag::create() writes a member's
report with one INSERT ... SELECT ... WHERE NOT EXISTS (reporter, object), the rule check_flag() already states,
with no schema change; a unique key would settle it for good but changes the table, so it is a separate owner decision.
The loser gets the same 409 "already reported". System reports (reporter 0) are not deduplicated.

Tests (VoteParallelRequestsTest, 5): the duplicate, retract, flip and report races fail on the old code; the outcomes
still fire once without a parallel request. Vote, Flag, Moderation and RaceCondition suites: 106 pass.
… and the app

The Appearance tab saved a blank accent field as an empty string. The email notifier, GET /app/config and the
settings GET read it with ?? and an empty string passes through, so every email type (the announcement preview,
the sign-up Confirm button, replies) rendered `background:;` white on white, the app got an empty accent, and
the settings GET returned a value that its own pattern refuses on the way back.

Settings gains one default (DEFAULT_ACCENT) and one resolver, Settings::accent_color(): the saved colour when it
is a valid hex, otherwise the default. The writer saves the default instead of an empty string, and the readers go
through the resolver: the email notifier, GET /app/config, Settings::read() and the Appearance field. The template
loader's "not set" check uses the constant instead of a second literal. The REST pattern is not loosened.
Sites that already hold an empty value need no migration: every reader resolves it. (Two whitespace-only alignment
fixes in the settings view came with it, because the commit gate lints the whole staged file.)

Tests (BlankAccentColorTest, 5): resolver, writer, a rendered email, settings GET and app config; four fail on the
old code. Settings, Notifier, Email, AppConfig and palette suites: 95 pass.
…p jetonomy no longer count as yes

The older `wp jetonomy` commands in class-cli.php read their flags by presence (! empty / isset), so a value of
false still counted: `demo-seed --model=false` started the destructive full reset of all Jetonomy content (blocked
only on production environments), `--force=false` replaced existing demo data, `import --dry-run=false` and
`trust-evaluate --dry-run=false` still dry-ran, and `qa --report=false` still wrote a report. The command classes
already read these through bool_arg(); this file sat outside the folders the cast scan reads.

Base_Command::flag_arg() is the one reader (bool_arg() now delegates to it) and all five flags in the file use it.
demo-seed reads --model and --force before anything runs, so a bad value stops it before the reset. A value that
is not a yes/no stops the command by name, as in the command classes.

Tests: CliArgumentCastTest now scans class-cli.php by flag name and checks flag_arg() for false/0/no/off (both fail
on the old code). All Jetonomy CLI suites: 369 tests pass.
…ommands are in the CLI guide

The 2.1.0 readme line and the what's-new page said `wp jetonomy trust-evaluate --dry-run` lists who would be
promoted; the command prints how many profiles it checked and how many members would be promoted, and its own
help text already said so. Both lines now say that.

10-wp-cli.md had no entry for any of the four older maintenance commands (recount, trust-evaluate, flush-rules,
backfill-activity); it has one section for them now, written from what each does, including the --type values of
recount and the fact that backfill-activity skips what is already logged.
…reen

The Me menu opens upward from the bottom bar, but `.jt-mobile-tab-menu` had no height limit (only the wide
"Start a topic in..." sheet had one), so with its five items plus the appended Moderation and Messages links
on a 390x320 screen its top edge sat 52px above the viewport: the first items could not be reached and nothing
scrolled. Measured before and after on this site with the real stylesheet and the menu's real markup:
top -52px (height 318 of 320) -> +74px (height 192, scrolls, first item visible, last reachable); at 390x844 it
is unchanged (318px, no scroll).

The limit moves into the base rule (60vh with a 60dvh override, so the phone's collapsing browser bars are
followed) with overflow-y: auto, and the wide sheet now inherits it instead of carrying its own copy. The other
absolutely positioned popovers were checked: the notification panel and instant results already cap their height,
the emoji picker is a fixed grid of a few emoji and the notification item menu is a short context menu.
jetonomy.css, jetonomy-rtl.css and both .min files are regenerated with grunt rtlcss cssmin; only those four change.

Tests (MobileTabMenuHeightCssTest): the cap is in the source and every built file, and the wide sheet has no second
copy; both fail on the old CSS.
…'s state refuse a change to it

Every writer of a space funnels through Space::update() (REST PATCH and DELETE, the wp-admin forms, access rules,
WP-CLI, the BuddyPress and Learnomy integrations), as its own comment says, but nothing could stop a write from
outside: an integration that owns a space's visibility, join policy or status (BuddyNext, for a forum linked to
a Space) had to guard each route separately and missed the rest.

The filter runs right after the type check, with the space id and the column data about to be written; a WP_Error
refuses the update and nothing is written. Callers already handle an error from Space::update() (the type check
returns one). With no filter attached behaviour is unchanged. Listed in audit/manifest.json, and the hook counts in
CLAUDE.md and readme.txt follow it (274 hooks, 152 filters).

Test: a filter that refuses a visibility change makes that update return its error and leaves the row unchanged,
while a title change under the same filter, and an update with no filter, are written.
…efusal, not a generic hand-over failure

Space::hand_over() read any non-true answer from Space::update() as "could not be handed over" (a 500). With
jetonomy_before_update_space a refusal is a deliberate answer with its own code and status, so a refused
archive-and-hand-over (the REST DELETE in transfer mode, the wp-admin delete) now puts the heir back as before and
returns that error unchanged.

Test: a filter refusing the status change makes hand_over() return the filter's error, with the space still active,
ownership unmoved and the heir back to no role.
…I and the access rule, not as done

Space::update() answers a WP_Error when jetonomy_before_update_space refuses a write, and four callers read any
non-false answer as success: `wp jetonomy space set-visibility`, `set-join-policy` and `set-settings` printed
"Success" while nothing was written, and an access rule's (bool) cast claimed it had switched the space to private.
The journeys now return the refusal as a failure (as update() already did) and the access rule reports false.
Callers that already handled the error (REST, the wp-admin form) or that ignore the result are unchanged.

Test: with a refusing filter, set_visibility, set_join_policy and update fail and the access rule does not claim to
have privatised the space; the first of them reported success on the old code.
…, not once per request

SpaceMember::join() ignored the result of JoinRequest::create_request() and fired jetonomy_join_request_created
whether or not a row was stored. The unique key (space, user, status) keeps one row, but 20 parallel requests
fired the hook 12 times and sent the space's admins 24 notifications, with 11 duplicate-entry errors in the log.

create_request() now keeps the expected duplicate out of the error log and answers 0 when it lost; join() then answers
already_pending, with no hook, when a pending request exists, and returns an error when the insert failed for any other
reason (it used to claim success and announce a request that was never stored). find_pending() is declared impure
for the analyser: its answer depends on the database, which is exactly why join() asks it a second time.

Test: a request whose insert loses to a parallel one answers already_pending and announces nothing; a single request is
announced once and a repeat is already pending. The first fails on the old code.
…ctions)

Covers the Pro reactions change: a parallel first reaction and a parallel remove fire nothing in the losing request, and
add, swap and remove without a parallel request fire once each.
…anged

BlockedUser::block() stored the block with INSERT IGNORE and fired jetonomy_user_blocked whether or not a row was
stored, so a repeat or 20 parallel requests announced one block 12 times; unblock() fired jetonomy_user_unblocked even
when there was nothing to remove. Both hooks now follow the affected rows: the request that stored (or removed) the row
fires it, and a repeat or a parallel one still answers success without announcing again.

Also the email guide's accent fallback said #3B82F6; it is #0073aa, and applies when the setting is blank or invalid.

Tests (BlockedUserHooksTest, 3): a block and its repeat announce once, a block that loses to a parallel one announces
nothing, an unblock and its repeat announce once; all three fail on the old code.
When a member voted up in one tab and down in another at the same moment, the request that lost answered success, but its
page lit the arrow it had clicked while the stored vote was the other one, because the response only said what the
request did, not what the member has.

POST and DELETE vote now also return user_vote (1, -1 or 0, read after the write), and the four click handlers (topic
and reply, up and down) light the arrows from it when it is present, falling back to what the click implies when an
older response lacks it. view.min.js is rebuilt (the only built script that changes).

Tests: the losing request of an opposite-direction pair reports the downvote that is stored (user_vote -1, unchanged),
and an ordinary vote and its undo report 1 and then 0.
…ders, and a CSS comment carries no hex colour

The release gate flagged SQL built with {$var}. Seven of them are now prepared with %i identifier placeholders (WordPress
6.2+, the plugin requires 6.7): the recount backfill's MAX(column) read, the 1.7.1 table rename and drop, the two 2.0.7
access-rule updates and the QA fixture's id-list delete. An admin.css comment named two hex colours, which the
"no hex outside :root" rule reads as a literal; it says "the default grey border" now.

The 35 other S4 hits (migrations and the forum importers) interpolate only table names built from the site prefix, with
no user value anywhere; the gate's own rule says that is not a violation, it just only recognises variables named
*table. They are left as they are rather than rewriting working, rarely exercised destructive code to satisfy a name pattern.
Migration, recount and QA-fixture suites: 142 tests pass.
…d the space feed dates are right outside UTC

Times are stored in UTC but were printed through five different WordPress calls (wp_date, date_i18n, mysql2date,
get_date_from_gmt and strtotime + date_i18n), each picking its own timezone. Jetonomy now has the time standard's helpers:
display_timezone() (the site timezone, through the jetonomy_display_timezone filter so a site can show each member their
own), date_label() (the one formatter) and datetime_local_input() (the edit field's value). Every flagged display in the
admin import history, the scheduled-post badges, the profile, topic, member list, edited mark, reply card and invite
expiry uses them, and the two save parsers (invite expiry, scheduled publish) read what was typed in display_timezone(), so an
edit field and its save can never disagree. Dates are now localised (get_date_from_gmt always printed English month names).

Real defects fixed with it: the space RSS feed labelled the stored UTC time with the site's offset (mysql2date('r')), so on any
non-UTC site every pubDate, lastBuildDate and Last-Modified was wrong; they are written in UTC now. Import run start and
finish times and the profile updated_at were stored in site-local time next to UTC columns; they use the UTC now() helper
(import history rows saved before this upgrade show shifted by the site offset until the next import).

Behaviour on a default site is otherwise the same. New filter listed in audit/manifest.json (275 hooks, 153 filters).

Tests (DisplayTimezoneTest, 5): day change across midnight, fallback for blank/zero/garbage, per-member timezone, no drift
through an invite-expiry save in the site and in a member timezone, UTC RSS dates. The release gate's TM row passes.
Adds the fixes and the two new filters to the 2.1.0 block in the action-prefix format: parallel votes, reports, join requests and
blocks count once, a blank accent colour, the wp jetonomy false flags, the phone Me menu, UTC feed dates, a refused space change
reported as refused, and the jetonomy_before_update_space and jetonomy_display_timezone filters. The earlier vote line now says
what is true now (voting or reporting at the same moment counts once, with one reputation change).
…tion catalogue for the re-tag

The release build rebuilds these from their sources: admin-rtl.css follows the admin.css comment edit, the hooks index follows
the manifest (the two new filters), and jetonomy.pot picks up the strings added since it was last generated (the 13 msgids QA
found missing among them). Generated output only; no source change.
… hands the space to a manager

When the last admin of a space is erased the privacy code hands it to a site administrator and archives it. With
jetonomy_before_update_space a plugin that owns the space's status (BuddyNext, for a forum linked to a Space) refuses the
archive, and the hand-over then gave up as a whole: the forum kept the erased account's id as its author and had no admin
or moderator row, so nothing could manage it.

The archive is only a safeguard. When it is refused the hand-over is retried without it (author and the new admin row), and the
last-resort path now writes the owner and the archive as two separate updates, so a refused archive cannot block the owner.

Test: erasing the sole admin of a space whose archive is refused leaves a live owner, a manager, and the space unarchived; it fails
on the old code (the erased id stayed the owner).
…t saved as "added"

A membership, role, capability or trust-level rule does nothing on a PUBLIC space: the permission engine checks visibility first, so
adding one switches the space to Private. When a plugin that owns the space's visibility refuses that (BuddyNext, for a forum
linked to a Space), the rule was saved anyway and the answer said "Access rule added" while the forum stayed open: proved on the
Local site, a guest got the forum (HTTP 200) and so did a member without the required capability. A site owner would believe paid
content was protected when it was not.

AccessRule::ensure_gate() now returns the refusal; the REST add-rule route and the wp-admin screen delete the rule they just created and
answer with it (409 / the message) instead of keeping an inert rule. enforce_gate_on_public_space() is unchanged for other callers.
Everyone and logged-in rules, which never change the space, are unaffected. The hooks reference lists jetonomy_before_update_space
and jetonomy_display_timezone.

Tests (AccessRuleOnProtectedSpaceTest): a refused privatise leaves no rule and answers 409 (the old code answered 201 and kept
it); without a refusal the space is made private and the rule kept; an everyone/logged-in rule is unaffected.
…ong-lived test database no longer fails them

Five QueueTest cases failed on every machine whose test database had been used before, which the release build's PHPUnit gate turns into
"do not tag". The history prune and the one-copy checks work across the whole `jetonomy` action group, but the test only cleared its own hook,
so rows left by other Jetonomy jobs and earlier runs (60 of the test hook itself, gravatar checks) changed the counts: 95 rows left where 25
were expected, 5 copies where 1 was expected. set_up and tear_down now clear the group. Not a product bug: the same five tests fail on the
released v2.1.0 and pass here, with no source change.
@vapvarun
vapvarun merged commit 3c13964 into main Nov 24, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant