[wp-trac] [WordPress Trac] #56244: Use a consistent parameter name for functions accepting a comment ID or object
WordPress Trac
noreply at wordpress.org
Thu Jul 21 00:25:29 UTC 2022
#56244: Use a consistent parameter name for functions accepting a comment ID or
object
----------------------------+-------------------------------------
Reporter: SergeyBiryukov | Owner: SergeyBiryukov
Type: enhancement | Status: accepted
Priority: normal | Milestone: 6.1
Component: Comments | Version:
Severity: normal | Resolution:
Keywords: | Focuses: docs, coding-standards
----------------------------+-------------------------------------
Comment (by peterwilsoncc):
[53729] affects the data sent to the `preprocess_comment` filter.
Prior to this change the user ID would be sent to the filter both as
`user_ID` and `user_id` when called from the modified function. After the
change this is no longer the case.
Based on a [https://wpdirectory.net/search/01G8F0GP4DHDY5ZWA3C3DXEW72
quick search of the plugin repo] I think this will affect some popular
plugins.
POC test for `wp_ajax_replyto_comment()`, add this method to the test
class `Tests_Ajax_ReplytoComment`:
{{{#!php
<?php
public function test_filter_args() {
// Become an administrator.
$this->_setRole( 'administrator' );
// Get a comment.
$comments = get_comments(
array(
'post_id' => self::$comment_post->ID,
)
);
$comment = array_pop( $comments );
$filter = new MockAction();
add_filter( 'preprocess_comment', array( $filter, 'filter' ) );
// Set up a default request.
$_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-
comment' );
$_POST['comment_ID'] = $comment->comment_ID;
$_POST['content'] = 'Lorem ipsum dolor sit
amet, consectetur adipiscing elit.';
$_POST['comment_post_ID'] = self::$comment_post->ID;
// Make the request.
try {
$this->_handleAjax( 'replyto-comment' );
} catch ( WPAjaxDieContinueException $e ) {
unset( $e );
}
// Check the filter was called with user_ID.
$args = $filter->get_args()[0][0];
$this->assertArrayHasKey( 'user_ID', $args );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56244#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list