Use comment status and type to set $maybe_notify default#10489
Use comment status and type to set $maybe_notify default#10489adamsilverstein wants to merge 20 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. You can also manually ask me to refresh this list by adding the 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. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Co-authored-by: Aaron Jorbin <aaronjorbin@users.noreply.github.com>
b823913 to
87f55c9
Compare
Co-authored-by: Weston Ruter <westonruter@gmail.com>
87f55c9 to
7c217dd
Compare
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
The get_comment() return value is filtered, so reassign $comment_id from the comment object to ensure consistency between the property checks and subsequent function calls. Also removes a redundant null check on $comment.
|
@westonruter whenever you have a moment, this is ready for review again. |
The filter override and default-value tests fail against trunk, where the approval check runs after the filter and silently vetoes a true result for unapproved comments.
The test passed 0 as an invalid comment ID, but get_comment() treats any empty ID as a request for the global $comment, which earlier tests in the same file leave populated - so the instanceof guard never triggered and the filter fired. Use a non-existent ID instead, which bypasses the fallback and exercises the early return. Test-only change.
The approval check moving ahead of the notify_post_author filter and the early return for invalid comment IDs are both observable to extenders, so they need @SInCE 7.1.0 entries on the function as well as the filter. Also moves the function description above the @SInCE tag per the inline documentation standards.
WP_Comment::$comment_ID is a numeric string, while both hooked call sites previously delivered an int and the filter docblock documents the param as int. Casting preserves strict comparisons in existing filter callbacks and keeps the documented type accurate.
Protects the two remaining default paths of the reordered logic: an unapproved note must still default to notifying (the note carve-out), and an approved comment's default must follow the comments_notify option.
Draft dev note for the 7.1 field guideThe
|
Trac ticket: https://core.trac.wordpress.org/ticket/64217
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.