WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 4 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: Priority: normal
Severity: normal Version: 3.4
Component: Database Keywords:
Focuses: Cc:
PR Number:

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 (4)

#2 @nacin
7 years ago

Why are you serializing the internal array?

#3 @sekatsim
7 years 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

#4 @chriscct7
4 years ago

  • Version changed from 3.4.1 to 3.4
Note: See TracTickets for help on using tickets.