From 4d28f9a7de1a40cf321edb86c0e4f94c0636fd90 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 25 Jun 2015 19:00:51 +0000 Subject: [PATCH] In `get_site_option()` and `get_option()`, ensure that `$notoptions` is an array before writing to it. Prevents a flood of `Cannot use a scalar value as an array`, because `$notoptions` is otherwise set to the result of `wp_cache_get()`, which returns `mixed`. Props hauvong. Fixes #31147. git-svn-id: https://develop.svn.wordpress.org/trunk@32943 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/option.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index 5ba890ec6c..1157b56d94 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -83,6 +83,9 @@ function get_option( $option, $default = false ) { $value = $row->option_value; wp_cache_add( $option, $value, 'options' ); } else { // option does not exist, so we must cache its non-existence + if ( ! is_array( $notoptions ) ) { + $notoptions = array(); + } $notoptions[$option] = true; wp_cache_set( 'notoptions', $notoptions, 'options' ); @@ -1024,6 +1027,9 @@ function get_site_option( $option, $default = false, $use_cache = true ) { $value = maybe_unserialize( $value ); wp_cache_set( $cache_key, $value, 'site-options' ); } else { + if ( ! is_array( $notoptions ) ) { + $notoptions = array(); + } $notoptions[$option] = true; wp_cache_set( $notoptions_key, $notoptions, 'site-options' );