Ticket #4429 (closed defect (bug): fixed)
add_option followed by update_option not always working
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | high | Milestone: | 2.2.2 |
| Component: | Administration | Version: | 2.2 |
| Severity: | major | Keywords: | add_option update_option has-patch 2nd-opinion |
| Cc: |
Description
I have an update script that brings a plugin from any version up to the current version. Early on there is an add_option request. Later I need to add to the content so I perform a get_option, modify the content and perform an update_option. This also happens a second time in the script. Results can vary. For some the sequence works fine. For others the final option content may only contain the final two 'update' calls having lost the original. In tests I have just performed I ended up with two option rows (with the same option_name) - the first with the original content, the second with the two modifications combined. I do not believe this ever happened (to my knowledge) prior to 2.2 but seems to be quite common on 2.2. It's almost as if the subsequent calls are not pulling the original option from the cache.
Attachments
Change History
comment:2
markjaquith — 5 years ago
- Owner changed from anonymous to markjaquith
- Status changed from new to assigned
- Milestone changed from 2.4 (future) to 2.3 (trunk)
Subscribe to Comments has been triggering this bug too. I finally nailed down the issue.
add_option() tries to erase the "notoptions" cache entry for the option too early... that is, it performs it before a get_option() call. The get_option() call marks (or re-marks) the option as "notoptions" (caches its non-existence). So now when you call update_option(), it thinks the option doesn't exist, so it adds a new one. Patches coming.
comment:3
markjaquith — 5 years ago
- Keywords has-patch 2nd-opinion added
- Priority changed from normal to high
- Severity changed from normal to major
This is a pretty critical function, so I'd appreciate a second pair of eyes on these patches.
comment:4
markjaquith — 5 years ago
- Status changed from assigned to closed
- Resolution set to fixed
comment:5
markjaquith — 5 years ago
- Status changed from closed to reopened
- Resolution fixed deleted
- Milestone changed from 2.3 (trunk) to 2.2.2
Re-open for 2.2.2
comment:6
markjaquith — 5 years ago
- Status changed from reopened to closed
- Resolution set to fixed

