Repository navigation
Support Forums: Audit Log: Avoid a PHP warning when a forum role is set to the user's current role - #1092
Support Forums: Audit Log: Avoid a PHP warning when a forum role is set to the user's current role#1092bor0 wants to merge 2 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
|
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 42 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…et to the user's current role. bbPress passes `false` to the `bbp_set_user_role` filter when the user already has the requested role. The previously removed role was kept for the rest of the request, so a repeat call in the same request (for example while erasing a user's personal data) skipped the no-change bail-out and called `get_role( false )->name`. Clear the tracked role once it's been read, bail when no role was set, and use the role slugs directly, which is what `WP_Role::$name` held anyway. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
6fc18e0 to
090ebbe
Compare
Fixes a PHP warning in the support forums audit log:
Cause
bbp_set_user_role()passesfalseto thebbp_set_user_rolefilter when the user already has the requested role:Audit_Logrecords the removed role in$this->last_role_changebut never clears it. When the forum role is set twice for the same user in one request (which the production warning suggests happens when a personal data erasure request is confirmed; that handler isn't in this repository), the second call sees$new_role = falsealongside the stale previous role from the first call. That skips the$new_role === $previous_rolebail-out and reachesget_role( false )->name.Fix
get_role()->name.WP_Role::$nameholds the slug, so the note text is unchanged.Testing
On a sandbox, via
wp eval-file, with note writes blocked by a throwingwporg_bbp_forum_role_changed_note_textfilter:$new_role = falsegivesErrorException: Attempt to read property "name" on null @ class-audit-log.php:120, matching production.false: returns without logging.bbp_moderator→bbp_blockedchange still logsForum role changed to bbp_blocked from bbp_moderator via wordpress.org.(same wording as before).falseafter that change: returns without logging.php -lpasses; no new PHPCS violations.🤖 Generated with Claude Code
Summary by CodeRabbit