Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r46779 r47122  
    7070
    7171    if ( ! wp_installing() ) {
    72         // prevent non-existent options from triggering multiple queries
     72        // Prevent non-existent options from triggering multiple queries.
    7373        $notoptions = wp_cache_get( 'notoptions', 'options' );
    7474        if ( isset( $notoptions[ $option ] ) ) {
     
    100100                $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
    101101
    102                 // Has to be get_row instead of get_var because of funkiness with 0, false, null values
     102                // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
    103103                if ( is_object( $row ) ) {
    104104                    $value = $row->option_value;
    105105                    wp_cache_add( $option, $value, 'options' );
    106                 } else { // option does not exist, so we must cache its non-existence
     106                } else { // Option does not exist, so we must cache its non-existence.
    107107                    if ( ! is_array( $notoptions ) ) {
    108108                        $notoptions = array();
     
    128128    }
    129129
    130     // If home is not set use siteurl.
     130    // If home is not set, use siteurl.
    131131    if ( 'home' == $option && '' == $value ) {
    132132        return get_option( 'siteurl' );
     
    480480    $value = sanitize_option( $option, $value );
    481481
    482     // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
     482    // Make sure the option doesn't already exist.
     483    // We can check the 'notoptions' cache before we ask for a DB query.
    483484    $notoptions = wp_cache_get( 'notoptions', 'options' );
    484485    if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
     
    517518    }
    518519
    519     // This option exists now
    520     $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh
     520    // This option exists now.
     521    $notoptions = wp_cache_get( 'notoptions', 'options' ); // Yes, again... we need it to be fresh.
    521522    if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
    522523        unset( $notoptions[ $option ] );
     
    569570    wp_protect_special_option( $option );
    570571
    571     // Get the ID, if no ID then return
     572    // Get the ID, if no ID then return.
    572573    $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) );
    573574    if ( is_null( $row ) ) {
     
    708709        $transient_option = '_transient_' . $transient;
    709710        if ( ! wp_installing() ) {
    710             // If option is not in alloptions, it is not autoloaded and thus has a timeout
     711            // If option is not in alloptions, it is not autoloaded and thus has a timeout.
    711712            $alloptions = wp_load_alloptions();
    712713            if ( ! isset( $alloptions[ $transient_option ] ) ) {
     
    882883
    883884    if ( ! is_multisite() ) {
    884         // non-Multisite stores site transients in the options table.
     885        // Single site stores site transients in the options table.
    885886        $wpdb->query(
    886887            $wpdb->prepare(
     
    941942        $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] );
    942943
    943         // No change or both empty
     944        // No change or both empty.
    944945        if ( $cookie == $settings ) {
    945946            return;
     
    949950        $current    = isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ) : 0;
    950951
    951         // The cookie is newer than the saved value. Update the user_option and leave the cookie as-is
     952        // The cookie is newer than the saved value. Update the user_option and leave the cookie as-is.
    952953        if ( $current > $last_saved ) {
    953954            update_user_option( $user_id, 'user-settings', $cookie, false );
     
    10641065        $cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] );
    10651066
    1066         if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char
     1067        if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char.
    10671068            parse_str( $cookie, $user_settings );
    10681069        }
     
    12611262    }
    12621263
    1263     // prevent non-existent options from triggering multiple queries
     1264    // Prevent non-existent options from triggering multiple queries.
    12641265    $notoptions_key = "$network_id:notoptions";
    12651266    $notoptions     = wp_cache_get( $notoptions_key, 'site-options' );
     
    12951296            $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
    12961297
    1297             // Has to be get_row instead of get_var because of funkiness with 0, false, null values
     1298            // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
    12981299            if ( is_object( $row ) ) {
    12991300                $value = $row->meta_value;
     
    13901391        $cache_key = "$network_id:$option";
    13911392
    1392         // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
     1393        // Make sure the option doesn't already exist.
     1394        // We can check the 'notoptions' cache before we ask for a DB query.
    13931395        $notoptions = wp_cache_get( $notoptions_key, 'site-options' );
    13941396        if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
     
    14161418        wp_cache_set( $cache_key, $value, 'site-options' );
    14171419
    1418         // This option exists now
    1419         $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // yes, again... we need it to be fresh
     1420        // This option exists now.
     1421        $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // Yes, again... we need it to be fresh.
    14201422        if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
    14211423            unset( $notoptions[ $option ] );
Note: See TracChangeset for help on using the changeset viewer.