Make WordPress Core

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: mikengarrett's profile MikeNGarrett 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:


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)

32848.diff (510 bytes) - added by MikeNGarrett 8 years ago.
Patch #1
32848.2.diff (5.1 KB) - added by MikeNGarrett 8 years ago.
Patch 2 - replace all isset in option.php

Download all attachments as: .zip

Change History (6)

8 years ago

Patch #1

This ticket was mentioned in Slack in #core by mikengarrett. View the logs.

8 years ago

#2 @MikeNGarrett
8 years ago

Co-contributor: @tndavide, @jipmoors

Last edited 8 years ago by MikeNGarrett (previous) (diff)

#3 @MikeNGarrett
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.

8 years ago

Patch 2 - replace all isset in option.php

#6 @MikeNGarrett
5 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.

Note: See TracTickets for help on using tickets.