WordPress.org

Make WordPress Core

Opened 23 months ago

Last modified 23 months ago

#21762 new defect (bug)

Storing a multidimensional array using register_setting double-serializes subarrays identified with a string

Reported by: sekatsim Owned by: sekatsim
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.4.1
Component: Database Keywords:
Focuses: Cc:

Description

Storing a multidimensional array, such as $options['my-option'][$id] = "value", into the database using register_setting results in the "my-option" string getting double serialized. The option_value is stored as:

s:9:"'my-option'";a:1:{s:9:"option-id";s:5:"value";}

The my-option array is encased in both single and double quotes, so that isset($options['option-id'] evaluates false, but isset($options["'option-id'"] evaluates true.

Change History (3)

comment:2 nacin23 months ago

Why are you serializing the internal array?

comment:3 sekatsim23 months ago

I'm not.. it's automatically serialized whenever someone hits "Save Settings" on an options page and the array is passed through register_setting

Note: See TracTickets for help on using tickets.