Make WordPress Core


Ignore:
Timestamp:
05/24/2021 07:58:13 PM (3 years 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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.