[wp-trac] [WordPress Trac] #58238: comment_text filter not applied with correct number of arguments within REST API
WordPress Trac
noreply at wordpress.org
Wed May 3 03:17:47 UTC 2023
#58238: comment_text filter not applied with correct number of arguments within
REST API
--------------------------+-----------------------------
Reporter: sjregan | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 6.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Continuation of tickets #38314 and #24913
The filter is defined here:
wp-includes/comment-template.php:1057
{{{#!php
<?php
/**
* Filters the text of a comment to be displayed.
*
* @since 1.2.0
*
* @see Walker_Comment::comment()
*
* @param string $comment_text Text of the current comment.
* @param WP_Comment|null $comment The comment object. Null if not
found.
* @param array $args An array of arguments.
*/
echo apply_filters( 'comment_text', $comment_text, $comment, $args );
}}}
In the REST API:
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:1092
it is called with:
{{{#!php
<?php
if ( in_array( 'content', $fields, true ) ) {
$data['content'] = array(
/** This filter is documented in wp-includes/comment-template.php
*/
'rendered' => apply_filters( 'comment_text',
$comment->comment_content, $comment ),
'raw' => $comment->comment_content,
);
}
}}}
Hooks added expecting three arguments will cause a fatal error. Previous
fixes have involved passing an empty array as the third parameter when
applying the filter.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58238>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list