#31119 closed defect (bug) (fixed)
`add_option()` with `$autoload = false` adds option with autoload of "yes"
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| 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)
Change History (5)
#2
@
11 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. :)
+1, I've hit this more than once.