Changeset 47122 for trunk/src/wp-includes/option.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/option.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/option.php
r46779 r47122 70 70 71 71 if ( ! wp_installing() ) { 72 // prevent non-existent options from triggering multiple queries72 // Prevent non-existent options from triggering multiple queries. 73 73 $notoptions = wp_cache_get( 'notoptions', 'options' ); 74 74 if ( isset( $notoptions[ $option ] ) ) { … … 100 100 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); 101 101 102 // Has to be get_row instead of get_var because of funkiness with 0, false, null values102 // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values. 103 103 if ( is_object( $row ) ) { 104 104 $value = $row->option_value; 105 105 wp_cache_add( $option, $value, 'options' ); 106 } else { // option does not exist, so we must cache its non-existence106 } else { // Option does not exist, so we must cache its non-existence. 107 107 if ( ! is_array( $notoptions ) ) { 108 108 $notoptions = array(); … … 128 128 } 129 129 130 // If home is not set use siteurl.130 // If home is not set, use siteurl. 131 131 if ( 'home' == $option && '' == $value ) { 132 132 return get_option( 'siteurl' ); … … 480 480 $value = sanitize_option( $option, $value ); 481 481 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. 483 484 $notoptions = wp_cache_get( 'notoptions', 'options' ); 484 485 if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { … … 517 518 } 518 519 519 // This option exists now 520 $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh520 // This option exists now. 521 $notoptions = wp_cache_get( 'notoptions', 'options' ); // Yes, again... we need it to be fresh. 521 522 if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { 522 523 unset( $notoptions[ $option ] ); … … 569 570 wp_protect_special_option( $option ); 570 571 571 // Get the ID, if no ID then return 572 // Get the ID, if no ID then return. 572 573 $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ); 573 574 if ( is_null( $row ) ) { … … 708 709 $transient_option = '_transient_' . $transient; 709 710 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. 711 712 $alloptions = wp_load_alloptions(); 712 713 if ( ! isset( $alloptions[ $transient_option ] ) ) { … … 882 883 883 884 if ( ! is_multisite() ) { 884 // non-Multisite stores site transients in the options table.885 // Single site stores site transients in the options table. 885 886 $wpdb->query( 886 887 $wpdb->prepare( … … 941 942 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] ); 942 943 943 // No change or both empty 944 // No change or both empty. 944 945 if ( $cookie == $settings ) { 945 946 return; … … 949 950 $current = isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ) : 0; 950 951 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. 952 953 if ( $current > $last_saved ) { 953 954 update_user_option( $user_id, 'user-settings', $cookie, false ); … … 1064 1065 $cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] ); 1065 1066 1066 if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char 1067 if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char. 1067 1068 parse_str( $cookie, $user_settings ); 1068 1069 } … … 1261 1262 } 1262 1263 1263 // prevent non-existent options from triggering multiple queries1264 // Prevent non-existent options from triggering multiple queries. 1264 1265 $notoptions_key = "$network_id:notoptions"; 1265 1266 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); … … 1295 1296 $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) ); 1296 1297 1297 // Has to be get_row instead of get_var because of funkiness with 0, false, null values1298 // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values. 1298 1299 if ( is_object( $row ) ) { 1299 1300 $value = $row->meta_value; … … 1390 1391 $cache_key = "$network_id:$option"; 1391 1392 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. 1393 1395 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); 1394 1396 if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { … … 1416 1418 wp_cache_set( $cache_key, $value, 'site-options' ); 1417 1419 1418 // This option exists now 1419 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // yes, again... we need it to be fresh1420 // This option exists now. 1421 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // Yes, again... we need it to be fresh. 1420 1422 if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { 1421 1423 unset( $notoptions[ $option ] );
Note: See TracChangeset
for help on using the changeset viewer.