Skip to:

Opened 2 years ago

Closed 21 months ago

#3141 closed defect (fixed)

bbp_check_for_moderation applies comment_max_links_url filter incorrectly

Reported by: jreade Owned by: johnjamesjacoby
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.5.13
Component: API - Moderation Keywords: commit


bbp_check_for_moderation function's filter call for comment_max_links_url does not pass content.

The function bbp_check_for_moderation() in includes/common/functions.php has this code:

        /** Max Links *************************************************************/

        $max_links = get_option( 'comment_max_links' );
        if ( !empty( $max_links ) ) {

                // How many links?
                $num_links = preg_match_all( '/<a [^>]*href/i', $content, $match_out );

                // Allow for bumping the max to include the user's URL
                $num_links = apply_filters( 'comment_max_links_url', $num_links, $_post['url'] );

                // Das ist zu viele links!
                if ( $num_links >= $max_links ) {
                        return false;

Lines 53-63 in comment.php in wp-includes states:

 * Filters the number of links found in a comment.
 * @since 3.0.0
 * @since 4.7.0 Added the `$comment` parameter.
 * @param int    $num_links The number of links found.
 * @param string $url       Comment author's URL. Included in allowed links total.
 * @param string $comment   Content of the comment.
$num_links = apply_filters( 'comment_max_links_url', $num_links, $url, $comment );

bbp_check_for_moderation should be edited to include the $content of the post.

Without adding the last parameter you get a PHP Warning: Missing argument 3 for {closure}()
if you try to create your own filter for comment_max_links_url.

Change History (2)

#1 @johnjamesjacoby
21 months ago

  • Keywords commit added; needs-patch removed
  • Milestone changed from Awaiting Review to 2.6
  • Owner set to johnjamesjacoby

#2 @johnjamesjacoby
21 months ago

  • Resolution set to fixed
  • Status changed from new to closed

In 6754:

Moderation: pass $content into comment_max_links_url filter.

This changes brings parity to changes made in WordPress 4.7.0.

Fixes #3141.

Note: See TracTickets for help on using tickets.