Make WordPress Core

Ticket #63137: 63137.patch

File 63137.patch, 7.4 KB (added by viralsampat, 8 weeks ago)

I have checked above mentioned issue and resolved it. Here, I have added my patch.

  • src/wp-admin/network/site-new.php

    diff --git src/wp-admin/network/site-new.php src/wp-admin/network/site-new.php
    index a3b0919155..55aebfe9aa 100644
    get_current_screen()->set_help_sidebar( 
    3636if ( isset( $_REQUEST['action'] ) && 'add-site' === $_REQUEST['action'] ) {
    3737        check_admin_referer( 'add-blog', '_wpnonce_add-blog' );
    3838
    39         if ( ! is_array( $_POST['blog'] ) ) {
     39        // Check post blog isset and not empty.
     40        if( isset( $_POST['blog'] ) && ! empty( $_POST['blog'] ) ) {
     41                if ( ! is_array( $_POST['blog'] ) ) {
     42                        wp_die( __( 'Cannot create an empty site.' ) );
     43                }
     44        } else {
    4045                wp_die( __( 'Cannot create an empty site.' ) );
    4146        }
    4247
    43         $blog   = $_POST['blog'];
     48        $blog   = isset( $_POST['blog'] ) ? $_POST['blog'] : '';
    4449        $domain = '';
    4550
    4651        $blog['domain'] = trim( $blog['domain'] );
  • src/wp-admin/network/site-settings.php

    diff --git src/wp-admin/network/site-settings.php src/wp-admin/network/site-settings.php
    index adfc95cfa9..7ae4d2e205 100644
    if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] && is 
    4040        switch_to_blog( $id );
    4141
    4242        $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
    43         foreach ( (array) $_POST['option'] as $key => $val ) {
    44                 $key = wp_unslash( $key );
    45                 $val = wp_unslash( $val );
    46                 if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options, true ) ) {
    47                         continue; // Avoids "0 is a protected WP option and may not be modified" error when editing blog options.
     43
     44        // Check post options isset and not empty.
     45        if( isset( $_POST['option'] ) && ! empty( $_POST['option'] ) ) {
     46                foreach ( (array) $_POST['option'] as $key => $val ) {
     47                        $key = wp_unslash( $key );
     48                        $val = wp_unslash( $val );
     49                        if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options, true ) ) {
     50                                continue; // Avoids "0 is a protected WP option and may not be modified" error when editing blog options.
     51                        }
     52                        update_option( $key, $val );
    4853                }
    49                 update_option( $key, $val );
    5054        }
    5155
    5256        /**
  • src/wp-admin/network/site-users.php

    diff --git src/wp-admin/network/site-users.php src/wp-admin/network/site-users.php
    index b3041176d3..ef76b165b0 100644
    if ( $action ) { 
    6161        switch ( $action ) {
    6262                case 'newuser':
    6363                        check_admin_referer( 'add-user', '_wpnonce_add-new-user' );
    64                         $user = $_POST['user'];
     64                        $user = isset( $_POST['user'] ) ? $_POST['user'] : '';
    6565                        if ( ! is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) {
    6666                                $update = 'err_new';
    6767                        } else {
  • src/wp-admin/network/sites.php

    diff --git src/wp-admin/network/sites.php src/wp-admin/network/sites.php
    index 69ee15d95c..e383365c8f 100644
    if ( isset( $_GET['action'] ) ) { 
    8282
    8383        if ( 'confirm' === $_GET['action'] ) {
    8484                // The action2 parameter contains the action being taken on the site.
    85                 $site_action = $_GET['action2'];
     85                $site_action = isset( $_GET['action2'] ) ? $_GET['action2'] : '';
    8686
    8787                if ( ! array_key_exists( $site_action, $manage_actions ) ) {
    8888                        wp_die( __( 'The requested action is not valid.' ) );
    if ( isset( $_GET['action'] ) ) { 
    161161                case 'delete_sites':
    162162                        check_admin_referer( 'ms-delete-sites' );
    163163
    164                         foreach ( (array) $_POST['site_ids'] as $site_id ) {
    165                                 $site_id = (int) $site_id;
    166 
    167                                 if ( is_main_site( $site_id ) ) {
    168                                         continue;
    169                                 }
    170 
    171                                 if ( ! current_user_can( 'delete_site', $site_id ) ) {
    172                                         $site         = get_site( $site_id );
    173                                         $site_address = untrailingslashit( $site->domain . $site->path );
    174 
    175                                         wp_die(
    176                                                 sprintf(
    177                                                         /* translators: %s: Site URL. */
    178                                                         __( 'Sorry, you are not allowed to delete the site %s.' ),
    179                                                         $site_address
    180                                                 ),
    181                                                 403
    182                                         );
     164                        // Check post site_ids isset and not empty.
     165                        if( isset( $_POST['site_ids'] ) && ! empty( $_POST['site_ids'] ) ) {
     166                                foreach ( (array) $_POST['site_ids'] as $site_id ) {
     167                                        $site_id = (int) $site_id;
     168       
     169                                        if ( is_main_site( $site_id ) ) {
     170                                                continue;
     171                                        }
     172       
     173                                        if ( ! current_user_can( 'delete_site', $site_id ) ) {
     174                                                $site         = get_site( $site_id );
     175                                                $site_address = untrailingslashit( $site->domain . $site->path );
     176       
     177                                                wp_die(
     178                                                        sprintf(
     179                                                                /* translators: %s: Site URL. */
     180                                                                __( 'Sorry, you are not allowed to delete the site %s.' ),
     181                                                                $site_address
     182                                                        ),
     183                                                        403
     184                                                );
     185                                        }
     186       
     187                                        $updated_action = 'all_delete';
     188                                        wpmu_delete_blog( $site_id, true );
    183189                                }
    184 
    185                                 $updated_action = 'all_delete';
    186                                 wpmu_delete_blog( $site_id, true );
     190                        } else {
     191                                wp_die( __( 'No sites selected.' ) );
    187192                        }
     193               
    188194                        break;
    189195
    190196                case 'allblogs':
  • src/wp-admin/network/themes.php

    diff --git src/wp-admin/network/themes.php src/wp-admin/network/themes.php
    index 9794c08f8f..e394f25d71 100644
    if ( $action ) { 
    173173                                <?php else : ?>
    174174                                        <p><?php _e( 'Are you sure you want to delete these themes?' ); ?></p>
    175175                                <?php endif; ?>
    176                                 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;">
     176                                <form method="post" action="<?php echo isset( $_SERVER['REQUEST_URI'] ) ? esc_url( $_SERVER['REQUEST_URI'] ) : ''; ?>" style="display:inline;">
    177177                                        <input type="hidden" name="verify-delete" value="1" />
    178178                                        <input type="hidden" name="action" value="delete-selected" />
    179179                                        <?php
    if ( $action ) { 
    220220                                );
    221221                        }
    222222
    223                         $paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1;
     223                        $paged = isset( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1;
    224224                        wp_redirect(
    225225                                add_query_arg(
    226226                                        array(
    if ( $action ) { 
    255255                        $auto_updates = (array) get_site_option( 'auto_update_themes', array() );
    256256
    257257                        if ( 'enable-auto-update' === $action ) {
    258                                 $auto_updates[] = $_GET['theme'];
     258                                $auto_updates[] = isset( $_GET['theme'] ) ? $_GET['theme'] : '';
    259259                                $auto_updates   = array_unique( $auto_updates );
    260260                                $referer        = add_query_arg( 'enabled-auto-update', 1, $referer );
    261261                        } elseif ( 'disable-auto-update' === $action ) {
  • src/wp-admin/network/user-new.php

    diff --git src/wp-admin/network/user-new.php src/wp-admin/network/user-new.php
    index 0f7eba1c2d..810cec5e9c 100644
    if ( isset( $_REQUEST['action'] ) && 'add-user' === $_REQUEST['action'] ) { 
    3737                wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
    3838        }
    3939
    40         if ( ! is_array( $_POST['user'] ) ) {
     40        // Check post user isset and not empty.
     41        if( isset( $_POST['user'] ) && ! empty( $_POST['user'] ) ) {
     42                if ( ! is_array( $_POST['user'] ) ) {
     43                        wp_die( __( 'Cannot create an empty user.' ) );
     44                }
     45        } else {
    4146                wp_die( __( 'Cannot create an empty user.' ) );
    4247        }
    43 
     48       
    4449        $user = wp_unslash( $_POST['user'] );
    4550
    4651        $user_details = wpmu_validate_user_signup( $user['username'], $user['email'] );
  • src/wp-admin/network/users.php

    diff --git src/wp-admin/network/users.php src/wp-admin/network/users.php
    index 7ddd5f40a6..764a13ebcb 100644
    if ( isset( $_GET['action'] ) ) { 
    2626
    2727                        check_admin_referer( 'deleteuser' );
    2828
    29                         $id = (int) $_GET['id'];
     29                        $id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';
    3030                        if ( $id > 1 ) {
    3131                                $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle arrays.
    3232