Make WordPress Core

Changeset 59957


Ignore:
Timestamp:
03/09/2025 11:02:41 PM (7 weeks ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in check_comment().

Follow-up to [1012], [1737], [48121].

Props aristath, poena, afercia, SergeyBiryukov.
See #62279.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r59915 r59957  
    4141
    4242    // If manual moderation is enabled, skip all checks and return false.
    43     if ( 1 == get_option( 'comment_moderation' ) ) {
     43    if ( '1' === get_option( 'comment_moderation' ) ) {
    4444        return false;
    4545    }
     
    127127     * email address. If both checks pass, return true. Otherwise, return false.
    128128     */
    129     if ( 1 == get_option( 'comment_previously_approved' ) ) {
     129    if ( '1' === get_option( 'comment_previously_approved' ) ) {
    130130        if ( 'trackback' !== $comment_type && 'pingback' !== $comment_type && '' !== $author && '' !== $email ) {
    131131            $comment_user = get_user_by( 'email', wp_unslash( $email ) );
    132132            if ( ! empty( $comment_user->ID ) ) {
    133                 $ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1' LIMIT 1", $comment_user->ID ) );
     133                $ok_to_comment = $wpdb->get_var(
     134                    $wpdb->prepare(
     135                        "SELECT comment_approved
     136                        FROM $wpdb->comments
     137                        WHERE user_id = %d
     138                        AND comment_approved = '1'
     139                        LIMIT 1",
     140                        $comment_user->ID
     141                    )
     142                );
    134143            } else {
    135144                // expected_slashed ($author, $email)
    136                 $ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE comment_author = %s AND comment_author_email = %s and comment_approved = '1' LIMIT 1", $author, $email ) );
     145                $ok_to_comment = $wpdb->get_var(
     146                    $wpdb->prepare(
     147                        "SELECT comment_approved
     148                        FROM $wpdb->comments
     149                        WHERE comment_author = %s
     150                        AND comment_author_email = %s
     151                        AND comment_approved = '1'
     152                        LIMIT 1",
     153                        $author,
     154                        $email
     155                    )
     156                );
    137157            }
    138             if ( ( 1 == $ok_to_comment ) &&
    139                 ( empty( $mod_keys ) || ! str_contains( $email, $mod_keys ) ) ) {
    140                     return true;
     158
     159            if ( '1' === $ok_to_comment && ( empty( $mod_keys ) || ! str_contains( $email, $mod_keys ) ) ) {
     160                return true;
    141161            } else {
    142162                return false;
Note: See TracChangeset for help on using the changeset viewer.