WordPress.org

Make WordPress Core

Changeset 50981


Ignore:
Timestamp:
05/24/2021 07:58:13 PM (6 months ago)
Author:
desrosj
Message:

General: Avoid unnecessary calls to update_user_option().

The update_user_option() function is a way to update a user meta value after adding a blog’s prefix to the beginning of the meta key. But when the fourth parameter is true, the behavior is exactly the same as calling update_user_meta() directly.

This replaces all instances of update_user_option() when the fourth parameter is true in Core with a direct call to update_user_meta() to prevent an unnecessary call to update_user_option().

Props johnjamesjacoby, zkancs, obenland, desrosj.
Fixes #43339.

Location:
trunk/src
Files:
7 edited

Legend:

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

    r50831 r50981  
    375375         */
    376376        if ( $ip_changed || $search ) {
    377             update_user_option( $user_id, 'community-events-location', $events['location'], true );
     377            update_user_meta( $user_id, 'community-events-location', $events['location'] );
    378378        }
    379379
     
    17341734
    17351735    if ( is_array( $closed ) ) {
    1736         update_user_option( $user->ID, "closedpostboxes_$page", $closed, true );
     1736        update_user_meta( $user->ID, "closedpostboxes_$page", $closed );
    17371737    }
    17381738
     
    17401740        // Postboxes that are always shown.
    17411741        $hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) );
    1742         update_user_option( $user->ID, "metaboxhidden_$page", $hidden, true );
     1742        update_user_meta( $user->ID, "metaboxhidden_$page", $hidden );
    17431743    }
    17441744
     
    17651765
    17661766    $hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array();
    1767     update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true );
     1767    update_user_meta( $user->ID, "manage{$page}columnshidden", $hidden );
    17681768
    17691769    wp_die( 1 );
     
    19201920
    19211921    if ( $order ) {
    1922         update_user_option( $user->ID, "meta-box-order_$page", $order, true );
     1922        update_user_meta( $user->ID, "meta-box-order_$page", $order );
    19231923    }
    19241924
    19251925    if ( $page_columns ) {
    1926         update_user_option( $user->ID, "screen_layout_$page", $page_columns, true );
     1926        update_user_meta( $user->ID, "screen_layout_$page", $page_columns );
    19271927    }
    19281928
  • trunk/src/wp-admin/includes/nav-menu.php

    r50505 r50981  
    155155    if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
    156156        $user = wp_get_current_user();
    157         update_user_option(
     157        update_user_meta(
    158158            $user->ID,
    159159            'managenav-menuscolumnshidden',
     
    164164                3 => 'description',
    165165                4 => 'title-attribute',
    166             ),
    167             true
     166            )
    168167        );
    169168    }
     
    200199
    201200    $user = wp_get_current_user();
    202     update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
     201    update_user_meta( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes );
    203202}
    204203
  • trunk/src/wp-admin/includes/upgrade.php

    r49764 r50981  
    8989            $message       = __( '<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.' );
    9090            $user_id       = wp_create_user( $user_name, $user_password, $user_email );
    91             update_user_option( $user_id, 'default_password_nag', true, true );
     91            update_user_meta( $user_id, 'default_password_nag', true );
    9292            $email_password = true;
    9393            $user_created   = true;
  • trunk/src/wp-admin/includes/user.php

    r49927 r50981  
    483483    ) {
    484484        delete_user_setting( 'default_password_nag' );
    485         update_user_option( $user_ID, 'default_password_nag', false, true );
     485        update_user_meta( $user_ID, 'default_password_nag', false );
    486486    }
    487487}
     
    504504    if ( $new_data->user_pass != $old_data->user_pass ) {
    505505        delete_user_setting( 'default_password_nag' );
    506         update_user_option( $user_ID, 'default_password_nag', false, true );
     506        update_user_meta( $user_ID, 'default_password_nag', false );
    507507    }
    508508}
  • trunk/src/wp-admin/my-sites.php

    r47785 r50981  
    2828    $blog = get_site( (int) $_POST['primary_blog'] );
    2929    if ( $blog && isset( $blog->domain ) ) {
    30         update_user_option( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'], true );
     30        update_user_meta( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'] );
    3131        $updated = true;
    3232    } else {
  • trunk/src/wp-includes/script-loader.php

    r50973 r50981  
    17901790    if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) {
    17911791        $saved_location['ip'] = $current_ip_address;
    1792         update_user_option( $user_id, 'community-events-location', $saved_location, true );
     1792        update_user_meta( $user_id, 'community-events-location', $saved_location );
    17931793    }
    17941794
  • trunk/src/wp-includes/user.php

    r50935 r50981  
    28742874
    28752875    wp_set_password( $new_pass, $user->ID );
    2876     update_user_option( $user->ID, 'default_password_nag', false, true );
     2876    update_user_meta( $user->ID, 'default_password_nag', false );
    28772877
    28782878    /**
     
    29852985    }
    29862986
    2987     update_user_option( $user_id, 'default_password_nag', true, true ); // Set up the password change nag.
     2987    update_user_meta( $user_id, 'default_password_nag', true ); // Set up the password change nag.
    29882988
    29892989    /**
Note: See TracChangeset for help on using the changeset viewer.