Make WordPress Core


Ignore:
Timestamp:
07/01/2019 12:50:14 PM (6 years ago)
Author:
pento
Message:

Coding Standards: Fix the Squiz.PHP.DisallowMultipleAssignments violations in wp-admin.

See #47632.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r45507 r45583  
    670670    $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
    671671
    672     if ( ! $comment = get_comment( $id ) ) {
     672    $comment = get_comment( $id );
     673    if ( ! $comment ) {
    673674        wp_die( time() );
    674675    }
     
    779780
    780781    check_ajax_referer( "delete-meta_$id" );
    781     if ( ! $meta = get_metadata_by_mid( 'post', $id ) ) {
     782    $meta = get_metadata_by_mid( 'post', $id );
     783    if ( ! $meta ) {
    782784        wp_die( 1 );
    783785    }
     
    907909    $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
    908910
    909     if ( ! $comment = get_comment( $id ) ) {
     911    $comment = get_comment( $id );
     912    if ( ! $comment ) {
    910913        $x = new WP_Ajax_Response(
    911914            array(
     
    10111014    $tag = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
    10121015
    1013     if ( ! $tag || is_wp_error( $tag ) || ( ! $tag = get_term( $tag['term_id'], $taxonomy ) ) ) {
     1016    if ( $tag && ! is_wp_error( $tag ) ) {
     1017        $tag = get_term( $tag['term_id'], $taxonomy );
     1018    }
     1019
     1020    if ( ! $tag || is_wp_error( $tag ) ) {
    10141021        $message = __( 'An error has occurred. Please reload the page and try again.' );
    10151022        if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
     
    14911498                }
    14921499
    1493                 if ( ! $mid = add_meta( $pid ) ) {
     1500                $mid = add_meta( $pid );
     1501                if ( ! $mid ) {
    14941502                    wp_die( __( 'Please provide a custom field value.' ) );
    14951503                }
     
    14971505                wp_die( 0 );
    14981506            }
    1499         } elseif ( ! $mid = add_meta( $pid ) ) {
    1500             wp_die( __( 'Please provide a custom field value.' ) );
     1507        } else {
     1508            $mid = add_meta( $pid );
     1509            if ( ! $mid ) {
     1510                wp_die( __( 'Please provide a custom field value.' ) );
     1511            }
    15011512        }
    15021513
     
    15201531            wp_die( __( 'Please provide a custom field name.' ) );
    15211532        }
    1522         if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) {
     1533        $meta = get_metadata_by_mid( 'post', $mid );
     1534        if ( ! $meta ) {
    15231535            wp_die( 0 ); // if meta doesn't exist
    15241536        }
     
    15291541        }
    15301542        if ( $meta->meta_value != $value || $meta->meta_key != $key ) {
    1531             if ( ! $u = update_metadata_by_mid( 'post', $mid, $value, $key ) ) {
     1543            $u = update_metadata_by_mid( 'post', $mid, $value, $key );
     1544            if ( ! $u ) {
    15321545                wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
    15331546            }
     
    15711584        wp_die( -1 );
    15721585    }
    1573     if ( ! $user_id = edit_user() ) {
     1586    $user_id = edit_user();
     1587    if ( ! $user_id ) {
    15741588        wp_die( 0 );
    15751589    } elseif ( is_wp_error( $user_id ) ) {
     
    16251639    }
    16261640
    1627     if ( ! $user = wp_get_current_user() ) {
     1641    $user = wp_get_current_user();
     1642    if ( ! $user ) {
    16281643        wp_die( -1 );
    16291644    }
     
    16541669    }
    16551670
    1656     if ( ! $user = wp_get_current_user() ) {
     1671    $user = wp_get_current_user();
     1672    if ( ! $user ) {
    16571673        wp_die( -1 );
    16581674    }
     
    18081824    }
    18091825
    1810     if ( ! $user = wp_get_current_user() ) {
     1826    $user = wp_get_current_user();
     1827    if ( ! $user ) {
    18111828        wp_die( -1 );
    18121829    }
     
    18761893    check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
    18771894
    1878     if ( ! isset( $_POST['post_ID'] ) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) {
     1895    if ( ! isset( $_POST['post_ID'] ) || ! (int) $_POST['post_ID'] ) {
    18791896        wp_die();
    18801897    }
     1898
     1899    $post_ID = (int) $_POST['post_ID'];
    18811900
    18821901    if ( 'page' == $_POST['post_type'] ) {
     
    18901909    }
    18911910
    1892     if ( $last = wp_check_post_lock( $post_ID ) ) {
     1911    $last = wp_check_post_lock( $post_ID );
     1912    if ( $last ) {
    18931913        $last_user      = get_userdata( $last );
    18941914        $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
     
    19922012    }
    19932013
    1994     if ( ! isset( $_POST['tax_ID'] ) || ! ( $id = (int) $_POST['tax_ID'] ) ) {
     2014    if ( ! isset( $_POST['tax_ID'] ) || ! (int) $_POST['tax_ID'] ) {
    19952015        wp_die( -1 );
    19962016    }
     2017
     2018    $id = (int) $_POST['tax_ID'];
    19972019
    19982020    if ( ! current_user_can( 'edit_term', $id ) ) {
     
    22372259    }
    22382260
    2239     if ( $form = $wp_registered_widget_controls[ $widget_id ] ) {
     2261    $form = $wp_registered_widget_controls[ $widget_id ];
     2262    if ( $form ) {
    22402263        call_user_func_array( $form['callback'], $form['params'] );
    22412264    }
     
    23892412    }
    23902413
    2391     if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) {
     2414    $attachment = wp_prepare_attachment_for_js( $attachment_id );
     2415    if ( ! $attachment ) {
    23922416        wp_die();
    23932417    }
     
    25992623    }
    26002624
    2601     if ( $last_id = get_post_meta( $post_id, '_edit_last', true ) ) {
     2625    $last_id = get_post_meta( $post_id, '_edit_last', true );
     2626    if ( $last_id ) {
    26022627        $last_user = get_userdata( $last_id );
    26032628        /* translators: 1: display_name of last user, 2: date of last edit, 3: time of last edit. */
     
    26212646    }
    26222647    $post_id = (int) $_POST['post_ID'];
    2623     if ( ! $post = get_post( $post_id ) ) {
     2648    $post    = get_post( $post_id );
     2649    if ( ! $post ) {
    26242650        wp_die( 0 );
    26252651    }
     
    26852711    }
    26862712
    2687     if ( ! $id = absint( $_REQUEST['id'] ) ) {
     2713    $id = absint( $_REQUEST['id'] );
     2714    if ( ! $id ) {
    26882715        wp_send_json_error();
    26892716    }
    26902717
    2691     if ( ! $post = get_post( $id ) ) {
     2718    $post = get_post( $id );
     2719    if ( ! $post ) {
    26922720        wp_send_json_error();
    26932721    }
     
    27012729    }
    27022730
    2703     if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) {
     2731    $attachment = wp_prepare_attachment_for_js( $id );
     2732    if ( ! $attachment ) {
    27042733        wp_send_json_error();
    27052734    }
     
    27872816    }
    27882817
    2789     if ( ! $id = absint( $_REQUEST['id'] ) ) {
     2818    $id = absint( $_REQUEST['id'] );
     2819    if ( ! $id ) {
    27902820        wp_send_json_error();
    27912821    }
     
    28702900    }
    28712901
    2872     if ( ! $id = absint( $_REQUEST['id'] ) ) {
     2902    $id = absint( $_REQUEST['id'] );
     2903    if ( ! $id ) {
    28732904        wp_send_json_error();
    28742905    }
     
    29072938    }
    29082939
    2909     if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) {
     2940    $attachment = wp_prepare_attachment_for_js( $id );
     2941    if ( ! $attachment ) {
    29102942        wp_send_json_error();
    29112943    }
     
    29242956    }
    29252957
    2926     if ( ! $post_id = absint( $_REQUEST['post_id'] ) ) {
     2958    $post_id = absint( $_REQUEST['post_id'] );
     2959    if ( ! $post_id ) {
    29272960        wp_send_json_error();
    29282961    }
     
    29442977            continue;
    29452978        }
    2946         if ( ! $attachment = get_post( $attachment_id ) ) {
     2979        $attachment = get_post( $attachment_id );
     2980        if ( ! $attachment ) {
    29472981            continue;
    29482982        }
     
    29783012    $id = intval( $attachment['id'] );
    29793013
    2980     if ( ! $post = get_post( $id ) ) {
     3014    $post = get_post( $id );
     3015    if ( ! $post ) {
    29813016        wp_send_json_error();
    29823017    }
     
    29883023    if ( current_user_can( 'edit_post', $id ) ) {
    29893024        // If this attachment is unattached, attach it. Primarily a back compat thing.
    2990         if ( 0 == $post->post_parent && $insert_into_post_id = intval( $_POST['post_id'] ) ) {
     3025        $insert_into_post_id = intval( $_POST['post_id'] );
     3026        if ( 0 == $post->post_parent && $insert_into_post_id ) {
    29913027            wp_update_post(
    29923028                array(
     
    30533089    check_ajax_referer( 'media-send-to-editor', 'nonce' );
    30543090
    3055     if ( ! $src = wp_unslash( $_POST['src'] ) ) {
     3091    $src = wp_unslash( $_POST['src'] );
     3092    if ( ! $src ) {
    30563093        wp_send_json_error();
    30573094    }
     
    30613098    }
    30623099
    3063     if ( ! $src = esc_url_raw( $src ) ) {
     3100    $src = esc_url_raw( $src );
     3101    if ( ! $src ) {
    30643102        wp_send_json_error();
    30653103    }
    30663104
    3067     if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) ) {
     3105    $link_text = trim( wp_unslash( $_POST['link_text'] ) );
     3106    if ( ! $link_text ) {
    30683107        $link_text = wp_basename( $src );
    30693108    }
     
    30883127    // Figure out what filter to run:
    30893128    $type = 'file';
    3090     if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
    3091         && ( 'audio' == $ext_type || 'video' == $ext_type ) ) {
     3129    $ext  = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src );
     3130    if ( $ext ) {
     3131        $ext_type = wp_ext2type( $ext );
     3132        if ( 'audio' == $ext_type || 'video' == $ext_type ) {
    30923133            $type = $ext_type;
     3134        }
    30933135    }
    30943136
     
    31113153    }
    31123154
    3113     $response    = $data = array();
     3155    $response    = array();
     3156    $data        = array();
    31143157    $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' );
    31153158
     
    31933236    require ABSPATH . 'wp-admin/includes/revision.php';
    31943237
    3195     if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) {
     3238    $post = get_post( (int) $_REQUEST['post_id'] );
     3239    if ( ! $post ) {
    31963240        wp_send_json_error();
    31973241    }
     
    32023246
    32033247    // Really just pre-loading the cache here.
    3204     if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) {
     3248    $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) );
     3249    if ( ! $revisions ) {
    32053250        wp_send_json_error();
    32063251    }
Note: See TracChangeset for help on using the changeset viewer.