#31119 closed defect (bug) (fixed)
`add_option()` with `$autoload = false` adds option with autoload of "yes"
| Reported by: | dlh | Owned by: | nacin |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.2 |
| Component: | Options, Meta APIs | Version: | 4.1 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | Focuses: |
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
@
12 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. :)
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
+1, I've hit this more than once.