Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#41621 closed defect (bug) (fixed)

Customize: Removing setting from changeset generates PHP warning

Reported by: dlh's profile dlh Owned by: westonruter's profile westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

WP_Customize_Manager::save_changeset_post() includes a check for array_key_exists( 'value', $setting_params ) while looping through $args['data'].

This check can generate a warning when removing a setting from the changeset by passing 'setting_id' => null.

The attached patch includes a PHPUnit test demonstrating the issue; it should also be replicable in JS by calling wp.customize.requestChangesetUpdate( { 'setting_id': null } ).

The patch would verify that $setting_params is an array before checking array_key_exists().

Attachments (1)

41621.diff (1.8 KB) - added by dlh 8 years ago.

Download all attachments as: .zip

Change History (5)

@dlh
8 years ago

#1 @westonruter
8 years ago

  • Milestone changed from Awaiting Review to 4.9
  • Owner set to westonruter
  • Status changed from new to reviewing

#2 follow-up: @westonruter
8 years ago

@dlh @stubgo did you encounter this in writing unit tests for the changesets REST API endpoint? If not, could you add a unit test for it there as well to ensure that this use case is tested?

#3 @westonruter
8 years ago

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

In 41243:

Customize: Fix PHP warning raised when deleting a setting from changeset via passing null as params in WP_Customize_Manager::save_changeset_post().

Props dlh.
Fixes #41621.

#4 in reply to: ↑ 2 @dlh
8 years ago

Replying to westonruter:

@dlh @stubgo did you encounter this in writing unit tests for the changesets REST API endpoint? If not, could you add a unit test for it there as well to ensure that this use case is tested?

I encountered it separately from the endpoints, but it looks like @stubgo already wrote a test for it: https://github.com/WP-API/wp-api-customize-endpoints/blob/304196b1e65382393c10f883e3e1e050b54bc3a4/tests/test-customize-changesets-controller.php#L1906.

Note: See TracTickets for help on using tickets.