Opened 17 years ago
Closed 17 years ago
#4429 closed defect (bug) (fixed)
add_option followed by update_option not always working
Reported by: | YellowSwordfish | Owned by: | markjaquith |
---|---|---|---|
Milestone: | 2.2.2 | Priority: | high |
Severity: | major | Version: | 2.2 |
Component: | Administration | Keywords: | add_option update_option has-patch 2nd-opinion |
Focuses: | 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 (2)
Change History (8)
#2
@
17 years ago
- Milestone changed from 2.4 (future) to 2.3 (trunk)
- Owner changed from anonymous to markjaquith
- Status changed from new to assigned
#3
@
17 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.
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 aget_option()
call. Theget_option()
call marks (or re-marks) the option as "notoptions" (caches its non-existence). So now when you callupdate_option()
, it thinks the option doesn't exist, so it adds a new one. Patches coming.