Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#31119 closed defect (bug) (fixed)

`add_option()` with `$autoload = false` adds option with autoload of "yes"

Reported by: dlh's profile dlh Owned by: nacin's profile nacin
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.1
Component: Options, Meta APIs Keywords: has-patch commit
Focuses: Cc:

Description

The docs for add_option() say that the autoload parameter accepts string|bool.

This is accurate in that using a boolean won't cause an error, but the function checks only 'no' === $autoload, such that if you call add_option() with $autoload = false, your option will be autoloaded.

The attached patch adds support for false and adds a unit test for autoload values after add_option().

Alternatively, the docs could be updated to just string.

Attachments (1)

31119.patch (2.4 KB) - added by dlh 10 years ago.

Download all attachments as: .zip

Change History (5)

@dlh
10 years ago

#1 @rmccue
10 years ago

  • Keywords has-patch commit added
  • Milestone changed from Awaiting Review to 4.2

+1, I've hit this more than once.

#2 @nacin
10 years ago

One of the first things I ever worked on in WordPress core was #10788. This is where this originates, and yeah, I didn't do it right.

I'm going to re-jigger the unit test a bit to use a data provider (and avoid rand_str()). Please take a look as this is the preferred approach for writing tests of this nature, and that way the next time you submit a perfect bug report, and a perfect patch, it'll come with perfect tests, too. :)

#3 @nacin
10 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 31278:

Allow $autoload in add_option() to receive false.

props dllh.
fixes #31119.

#4 @nacin
10 years ago

Props dlh, not @dllh. Sorry. :-)

Note: See TracTickets for help on using tickets.