[wp-trac] [WordPress Trac] #52629: Introduce a better way to deprecate REST API parameters

WordPress Trac noreply at wordpress.org
Tue Feb 23 18:47:07 UTC 2021


#52629: Introduce a better way to deprecate REST API parameters
----------------------------+-----------------------------
 Reporter:  SergeyBiryukov  |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Future Release
Component:  REST API        |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+-----------------------------
Changes (by TimothyBlynJacobs):

 * milestone:  Awaiting Review => Future Release


Comment:

 My general thinking has been added something like this to a parameter
 definition.

 {{{#!php
 [
   'deprecated' => [
     'version' => '5.7',
     'message' => 'Use the new modifiers parameter',
     'transform_callback' => function( $request ) {
         $request['modifiers'] = do_something_with_old_value(
 $request['crop'] );
     }
   ]
 ];
 }}}

 Then the `WP_REST_Request` object would look for any parameters that have
 a deprecated flag, call the `transform_callback` if it exists, and then
 issue a deprecation warning of some kind.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52629#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list