Make WordPress Core

Ticket #58988: 58988.patch

File 58988.patch, 6.7 KB (added by nihar007, 7 months ago)

Patch added. I added strict comparison

  • src/wp-admin/includes/ajax-actions.php

    diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
    index ec3b6f0f36..135749c475 100644
    a b function wp_ajax_ajax_tag_search() { 
    148148         * Require $term_search_min_chars chars for matching (default: 2)
    149149         * ensure it's a non-negative, non-zero integer.
    150150         */
    151         if ( ( 0 == $term_search_min_chars ) || ( strlen( $search ) < $term_search_min_chars ) ) {
     151        if ( ( 0 === $term_search_min_chars ) || ( strlen( $search ) < $term_search_min_chars ) ) {
    152152                wp_die();
    153153        }
    154154
    function wp_ajax_wp_compression_test() { 
    205205                $force_gzip = ( defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP );
    206206                $test_str   = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."';
    207207
    208                 if ( 1 == $_GET['test'] ) {
     208                if ( 1 === $_GET['test'] ) {
    209209                        echo $test_str;
    210210                        wp_die();
    211                 } elseif ( 2 == $_GET['test'] ) {
     211                } elseif ( 2 === $_GET['test'] ) {
    212212                        if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
    213213                                wp_die( -1 );
    214214                        }
    function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { 
    509509        }
    510510
    511511        // Only do the expensive stuff on a page-break, and about 1 other time per page.
    512         if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
     512        if ( 0 === $total % $per_page || 1 === mt_rand( 1, $per_page ) ) {
    513513                $post_id = 0;
    514514                // What type of comment count are we looking for?
    515515                $status = 'all';
    function wp_ajax_delete_comment() { 
    729729        $status = wp_get_comment_status( $comment );
    730730        $delta  = -1;
    731731
    732         if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) {
     732        if ( isset( $_POST['trash'] ) && 1 === $_POST['trash'] ) {
    733733                if ( 'trash' === $status ) {
    734734                        wp_die( time() );
    735735                }
    736736
    737737                $r = wp_trash_comment( $comment );
    738         } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) {
     738        } elseif ( isset( $_POST['untrash'] ) && 1 === $_POST['untrash'] ) {
    739739                if ( 'trash' !== $status ) {
    740740                        wp_die( time() );
    741741                }
    function wp_ajax_delete_comment() { 
    752752                }
    753753
    754754                $r = wp_spam_comment( $comment );
    755         } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) {
     755        } elseif ( isset( $_POST['unspam'] ) && 1 === $_POST['unspam'] ) {
    756756                if ( 'spam' !== $status ) {
    757757                        wp_die( time() );
    758758                }
    function wp_ajax_delete_comment() { 
    763763                if ( ! isset( $_POST['comment_status'] ) || 'spam' !== $_POST['comment_status'] ) {
    764764                        $delta = 1;
    765765                }
    766         } elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) {
     766        } elseif ( isset( $_POST['delete'] ) && 1 === $_POST['delete'] ) {
    767767                $r = wp_delete_comment( $comment );
    768768        } else {
    769769                wp_die( -1 );
    function wp_ajax_dim_comment() { 
    996996
    997997        $current = wp_get_comment_status( $comment );
    998998
    999         if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) {
     999        if ( isset( $_POST['new'] ) && $_POST['new'] === $current ) {
    10001000                wp_die( time() );
    10011001        }
    10021002
    function wp_ajax_replyto_comment( $action ) { 
    13801380        if ( ! empty( $_POST['approve_parent'] ) ) {
    13811381                $parent = get_comment( $comment_parent );
    13821382
    1383                 if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_id ) {
     1383                if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID === $comment_post_id ) {
    13841384                        if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) {
    13851385                                wp_die( -1 );
    13861386                        }
    function wp_ajax_edit_comment() { 
    14791479        }
    14801480
    14811481        $position      = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
    1482         $checkbox      = ( isset( $_POST['checkbox'] ) && true == $_POST['checkbox'] ) ? 1 : 0;
     1482        $checkbox      = ( isset( $_POST['checkbox'] ) && true === $_POST['checkbox'] ) ? 1 : 0;
    14831483        $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
    14841484
    14851485        $comment = get_comment( $comment_id );
    function wp_ajax_save_widget() { 
    24012401
    24022402        foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
    24032403
    2404                 if ( $name == $id_base ) {
     2404                if ( $name === $id_base ) {
    24052405                        if ( ! is_callable( $control['callback'] ) ) {
    24062406                                continue;
    24072407                        }
    function wp_ajax_set_post_thumbnail() { 
    27272727                check_ajax_referer( "set_post_thumbnail-$post_id" );
    27282728        }
    27292729
    2730         if ( '-1' == $thumbnail_id ) {
     2730        if ( '-1' === $thumbnail_id ) {
    27312731                if ( delete_post_thumbnail( $post_id ) ) {
    27322732                        $return = _wp_post_thumbnail_html( null, $post_id );
    27332733                        $json ? wp_send_json_success( $return ) : wp_die( $return );
    function wp_ajax_send_attachment_to_editor() { 
    33083308                // If this attachment is unattached, attach it. Primarily a back compat thing.
    33093309                $insert_into_post_id = (int) $_POST['post_id'];
    33103310
    3311                 if ( 0 == $post->post_parent && $insert_into_post_id ) {
     3311                if ( 0 === $post->post_parent && $insert_into_post_id ) {
    33123312                        wp_update_post(
    33133313                                array(
    33143314                                        'ID'          => $id,
    function wp_ajax_send_attachment_to_editor() { 
    33193319        }
    33203320
    33213321        $url = empty( $attachment['url'] ) ? '' : $attachment['url'];
    3322         $rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $id ) == $url );
     3322        $rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $id ) === $url );
    33233323
    33243324        remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' );
    33253325
    function wp_ajax_crop_image() { 
    39913991                        $wp_site_icon = new WP_Site_Icon();
    39923992
    39933993                        // Skip creating a new attachment if the attachment is a Site Icon.
    3994                         if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) {
     3994                        if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) === $context ) {
    39953995
    39963996                                // Delete the temporary cropped file, we don't need it.
    39973997                                wp_delete_file( $cropped );