Changeset 56595 for trunk/src/wp-includes/option.php
- Timestamp:
- 09/15/2023 04:13:52 PM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/option.php
r56508 r56595 162 162 163 163 if ( ! wp_installing() ) { 164 // Prevent non-existent options from triggering multiple queries.165 $notoptions = wp_cache_get( 'notoptions', 'options' );166 167 // Prevent non-existent `notoptions` key from triggering multiple key lookups.168 if ( ! is_array( $notoptions ) ) {169 $notoptions = array();170 wp_cache_set( 'notoptions', $notoptions, 'options' );171 }172 173 if ( isset( $notoptions[ $option ] ) ) {174 /**175 * Filters the default value for an option.176 *177 * The dynamic portion of the hook name, `$option`, refers to the option name.178 *179 * @since 3.4.0180 * @since 4.4.0 The `$option` parameter was added.181 * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value.182 *183 * @param mixed $default_value The default value to return if the option does not exist184 * in the database.185 * @param string $option Option name.186 * @param bool $passed_default Was `get_option()` passed a default value?187 */188 return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default );189 }190 191 164 $alloptions = wp_load_alloptions(); 192 165 … … 197 170 198 171 if ( false === $value ) { 172 // Prevent non-existent options from triggering multiple queries. 173 $notoptions = wp_cache_get( 'notoptions', 'options' ); 174 175 // Prevent non-existent `notoptions` key from triggering multiple key lookups. 176 if ( ! is_array( $notoptions ) ) { 177 $notoptions = array(); 178 wp_cache_set( 'notoptions', $notoptions, 'options' ); 179 } elseif ( isset( $notoptions[ $option ] ) ) { 180 /** 181 * Filters the default value for an option. 182 * 183 * The dynamic portion of the hook name, `$option`, refers to the option name. 184 * 185 * @since 3.4.0 186 * @since 4.4.0 The `$option` parameter was added. 187 * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value. 188 * 189 * @param mixed $default_value The default value to return if the option does not exist 190 * in the database. 191 * @param string $option Option name. 192 * @param bool $passed_default Was `get_option()` passed a default value? 193 */ 194 return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); 195 } 196 199 197 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); 200 198 … … 204 202 wp_cache_add( $option, $value, 'options' ); 205 203 } else { // Option does not exist, so we must cache its non-existence. 206 if ( ! is_array( $notoptions ) ) {207 $notoptions = array();208 }209 210 204 $notoptions[ $option ] = true; 211 205 wp_cache_set( 'notoptions', $notoptions, 'options' );
Note: See TracChangeset
for help on using the changeset viewer.