Make WordPress Core

Changes between Initial Version and Version 4 of Ticket #34140


Ignore:
Timestamp:
10/04/2015 08:28:11 PM (9 years ago)
Author:
westonruter
Comment:

The reality is that the return value for WP_Customize_Setting::update() (a protected method) value is not even used in Core. As I can see, it is only used in WP_Customize_Setting::save() and is called as:

$this->update( $value );

So its return value is not used. The WP_Customize_Setting::save() method is called via WP_Customize_Manager::save():

		foreach ( $this->settings as $setting ) {
			$setting->save();
		}

The @return tag for the update() method says that the return value is supposed to be “The result of saving the value.” Currently this only returns a value (other than null/void) when it calls WP_Customize_Setting::_update_option(), since it does return a value. But WP_Customize_Setting::_update_theme_mod() does not return a value, and for custom types, calling do_action() also does not return a value.

In the latter case, it can just be changed to return whether there was was any callback added for that action to begin with.

See 34140.diff.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34140

    • Property Summary changed from WP_Customize_Setting::update( $value ) bad return value to Missing return values for WP_Customize_Setting::update( $value )
    • Property Version changed from 4.3.1 to 3.4
    • Property Milestone changed from Awaiting Review to 4.4
    • Property Keywords has-patch added
    • Property Type changed from defect (bug) to enhancement
  • Ticket #34140 – Description

    initial v4  
    1 The update function seems to need to return a value to get the Save & Publish button to change to Saved (I'm guessing).
    2 
    3 At any rate, the default: case has:
    4 
     1The docs for `WP_Customize_Setting::update()` method indicate it returns a value for “The result of saving the value.” For custom types (non-option or theme_mod) it will return via:
    52
    63{{{
     
    85}}}
    96
    10 The problem is that do_action does not return a value. This failure makes it impossible to save options with a custom setting type using preview. And as noted in another ticket, preview is seriously broken with the order(N(squared)) issue.
     7The problem is that `do_action()` does not return a value.