PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmField.php +9 -3 6.34 → trunk View file →
@@ -477,13 +477,19 @@
477 477 $new_values[ $col ] = $values[ $col ];
478 478 }
479 479 }
480 480
481 - $new_values['options'] = self::maybe_filter_options( $values['options'] );
481 + // Both option columns are stored serialized, but they do not accept the same shapes.
482 + // Choice fields pass options already serialized, as does FrmFieldsHelper::fill_field
483 + // when a field is duplicated, and fields with no choices pass an empty string, so a
484 + // missing key is the only thing worth defaulting. An is_array check here would throw
485 + // every one of those defaults away. field_options is always an array, so anything
486 + // else is invalid input, and replacing it stops consumers getting null.
487 + $new_values['options'] = self::maybe_filter_options( $values['options'] ?? array() );
482 488 $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
483 489 $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
484 490 $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
485 - $new_values['field_options'] = $values['field_options'];
491 + $new_values['field_options'] = isset( $values['field_options'] ) && is_array( $values['field_options'] ) ? $values['field_options'] : array();
486 492 $new_values['created_at'] = current_time( 'mysql', 1 );
487 493
488 494 if ( isset( $values['id'] ) ) {
489 495 $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
@@ -526,9 +532,9 @@
526 532 * See FrmAppHelper::allow_unfiltered_html.
527 533 *
528 534 * @since 5.0.08
529 535 *
530 - * @param array $options
536 + * @param array|string $options Already serialized for choice fields, and an empty string for fields with no choices.
531 537 *
532 538 * @return array
533 539 */
534 540 private static function maybe_filter_options( $options ) {