You appear to be a bot. Output may be restricted
Description
Do these two comments, without checking the comment_ID, "match"?
Usage
$bool = Akismet::comments_match( $comment1, $comment2 );
Parameters
- $comment1
- ( mixed ) required – A comment object or array.
- $comment2
- ( mixed ) required – A comment object or array.
Returns
bool Whether the two comments should be treated as the same comment.
Source
File name: akismet/class.akismet.php
Lines:
1 to 52 of 52
private static function comments_match( $comment1, $comment2 ) { $comment1 = (array) $comment1; $comment2 = (array) $comment2; // Set default values for these strings that we check in order to simplify // the checks and avoid PHP warnings. if ( ! isset( $comment1['comment_author'] ) ) { $comment1['comment_author'] = ''; } if ( ! isset( $comment2['comment_author'] ) ) { $comment2['comment_author'] = ''; } if ( ! isset( $comment1['comment_author_email'] ) ) { $comment1['comment_author_email'] = ''; } if ( ! isset( $comment2['comment_author_email'] ) ) { $comment2['comment_author_email'] = ''; } $comments_match = ( isset( $comment1['comment_post_ID'], $comment2['comment_post_ID'] ) && intval( $comment1['comment_post_ID'] ) == intval( $comment2['comment_post_ID'] ) && ( // The comment author length max is 255 characters, limited by the TINYTEXT column type. // If the comment author includes multibyte characters right around the 255-byte mark, they // may be stripped when the author is saved in the DB, so a 300+ char author may turn into // a 253-char author when it's saved, not 255 exactly. The longest possible character is // theoretically 6 bytes, so we'll only look at the first 248 bytes to be safe. substr( $comment1['comment_author'], 0, 248 ) == substr( $comment2['comment_author'], 0, 248 ) || substr( stripslashes( $comment1['comment_author'] ), 0, 248 ) == substr( $comment2['comment_author'], 0, 248 ) || substr( $comment1['comment_author'], 0, 248 ) == substr( stripslashes( $comment2['comment_author'] ), 0, 248 ) // Certain long comment author names will be truncated to nothing, depending on their encoding. || ( ! $comment1['comment_author'] && strlen( $comment2['comment_author'] ) > 248 ) || ( ! $comment2['comment_author'] && strlen( $comment1['comment_author'] ) > 248 ) ) && ( // The email max length is 100 characters, limited by the VARCHAR(100) column type. // Same argument as above for only looking at the first 93 characters. substr( $comment1['comment_author_email'], 0, 93 ) == substr( $comment2['comment_author_email'], 0, 93 ) || substr( stripslashes( $comment1['comment_author_email'] ), 0, 93 ) == substr( $comment2['comment_author_email'], 0, 93 ) || substr( $comment1['comment_author_email'], 0, 93 ) == substr( stripslashes( $comment2['comment_author_email'] ), 0, 93 ) // Very long emails can be truncated and then stripped if the [0:100] substring isn't a valid address. || ( ! $comment1['comment_author_email'] && strlen( $comment2['comment_author_email'] ) > 100 ) || ( ! $comment2['comment_author_email'] && strlen( $comment1['comment_author_email'] ) > 100 ) ) ); return $comments_match; }