Ticket #4429 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

add_option followed by update_option not always working

Reported by: YellowSwordfish Assigned to: 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 (1.3 kB) - added by markjaquith on 07/05/07 20:20:17.
add_option() fix for trunk
add_option_branches_2.2.diff (1.4 kB) - added by markjaquith on 07/05/07 20:20:36.
add_option() fix for 2.2.x

Change History

06/11/07 18:41:15 changed by foolswisdom

  • milestone set to 2.4 (future).

07/05/07 19:48:47 changed by markjaquith

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

07/05/07 20:20:17 changed by markjaquith

  • attachment add_option_trunk.diff added.

add_option() fix for trunk

07/05/07 20:20:36 changed by markjaquith

  • attachment add_option_branches_2.2.diff added.

add_option() fix for 2.2.x

07/05/07 20:21:36 changed by markjaquith

  • keywords changed from add_option update_option to add_option update_option has-patch 2nd-opinion.
  • 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.

07/07/07 04:06:30 changed by markjaquith

  • 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

07/07/07 04:06:58 changed by markjaquith

  • status changed from closed to reopened.
  • resolution deleted.
  • milestone changed from 2.3 (trunk) to 2.2.2.

Re-open for 2.2.2

07/07/07 04:08:05 changed by markjaquith

  • 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