Opened 8 years ago
Last modified 4 years ago
#32848 new defect (bug)
Null values for Update Options does not reset in $all_options
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.2 |
Component: | Cache API | Keywords: | has-patch needs-unit-tests bulk-reopened |
Focuses: | performance | Cc: |
Description
This is a fun, extremely niche case.
We were using the Settings API to save out options for a plugin when we came across a really frustrating scenario. Half the time our setting was returning values that were not accurate to the setting that was stored in the database and in cache.
Come to find, the value being returned from wp_load_alloptions was incorrect while every other instance was correct. In our case, these values were in the database, memcache, and the single value in wp-object-cache.
On line 319 of option.php, we're using isset to check the value in the array. This returns false if the value is NULL. This leads to all kinds of sadness.
I would propose we instead use array_key_exists
here to ensure we're getting true if the key is present in the array at all.
Attachments (2)
Change History (6)
This ticket was mentioned in Slack in #core by mikengarrett. View the logs.
8 years ago
#3
@
8 years ago
- Keywords has-patch needs-unit-tests added
I ran back through and realized there were quite a few places here that are using isset for assessing array keys existence. Here's a patch to switch all isset
to array_key_exists
. Next step, let's create some unit tests.
#6
@
4 years ago
- Keywords bulk-reopened added
This is still present, but it's a very narrow and uncommon case. I would be ok closing this.
https://core.trac.wordpress.org/browser/tags/5.1.1/src/wp-includes/option.php#L391
Patch #1