Repository navigation
Pattern Directory: Log flag status changes only once the flag is fully saved - #816
Conversation
…y saved Flag status notes were written on `transition_post_status`, which fires in the middle of `wp_insert_post()`, before the flag's terms and meta are saved, and before a REST request has finished. Move the logging to `wp_after_insert_post`, as the notifications already do, reading the old status from the post before the update. It runs at priority 5 so a new flag is still logged ahead of any status change `check_flag_threshold()` makes on the pattern. A flag without a reporter account is skipped instead of failing on the missing user. Fixes #480. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBAW4tyUi7UPtZygTvpuaQ
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 47 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
… stub Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… stub for every test - A flag whose reporter's account no longer exists was left out of the pattern's log entirely. Name the reporter "a deleted user" instead. - An update fired without the post as it was would be logged as a new flag. Skip it, since the old status is unknown. - Return on an unchanged status before looking up the user, as most saves now reach the hook without a status change. - Move the reason for the hook priority next to the add_action call. - Load the internal notes stub from the PHPUnit bootstrap. Defining it from one test file turned logging on for whichever tests ran after it, depending on load order. The test now only reads the stub's record, since the real plugin is never loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #480
Flag status notes on a pattern's log were written from
transition_post_statusin the Pattern Directory's logging code. That hook fires in the middle ofwp_insert_post(), before the flag's terms and meta are saved and before a REST request has finished, so a flag could be logged even when its save didn't complete.This moves the logging to
wp_after_insert_post, as the notifications already do, and reads the old status from the post before the update. It runs at priority 5 so a new flag is still logged ahead of any status change the flag threshold makes on the pattern. A flag with no reporter account is now skipped instead of raising a warning on the missing user; the alternative is logging it with a placeholder handle.Testing
bin/check(composer install, PHP lint, npm ci, CSS/JS lint, PHPUnit against WordPress nightly, Jest): all passed; PHPUnit OK (351 tests).Flag_Logging_Testcovers new, resolved and trashed flags, using an in-memory stand-in forwporg-internal-notes, which CI doesn't load. Its check that a flag is logged only once fully saved fails without the fix.Props ryelle.
Opened by the wporg bug pipeline, unattended. Risk: needs-review.
Generated by Claude Code
Summary by CodeRabbit