Ticket #4429 (closed defect (bug): fixed)

Opened 5 years ago

Last modified 5 years ago

add_option followed by update_option not always working

Reported by: YellowSwordfish Owned by: markjaquith
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

add_option_trunk.diff Download (1.3 KB) - added by markjaquith 5 years ago.
add_option() fix for trunk
add_option_branches_2.2.diff Download (1.4 KB) - added by markjaquith 5 years ago.
add_option() fix for 2.2.x

Change History

  • Milestone set to 2.4 (future)
  • 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.

add_option() fix for trunk

add_option() fix for 2.2.x

  • 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.

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [5788]) Properly unset notoptions cache in add_option() so that get_option() and update_option() work on the same load. fixes #4429 for trunk

  • 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

  • Status changed from reopened to closed
  • Resolution set to fixed

(In [5789]) Properly unset notoptions cache in add_option() so that get_option() and update_option() work on the same load. fixes #4429 for 2.2.x

Note: See TracTickets for help on using tickets.