[wp-trac] [WordPress Trac] #61580: WP_REST_Templates_Controller::get_wp_templates_author_text_field() doesn't always return value

WordPress Trac noreply at wordpress.org
Tue Jul 9 16:55:50 UTC 2024


#61580: WP_REST_Templates_Controller::get_wp_templates_author_text_field() doesn't
always return value
---------------------------+------------------------------
 Reporter:  antonvlasenko  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  REST API       |     Version:  trunk
 Severity:  minor          |  Resolution:
 Keywords:  has-patch      |     Focuses:  rest-api
---------------------------+------------------------------

Comment (by antonvlasenko):

 Replying to [comment:1 debarghyabanerjee]:
 > I have checked the core codebase, and if you check this function, you
 will find that it will always return a string, which will be one of the
 expected values/cases.
 >{{{
 >WP_REST_Templates_Controller::get_wp_templates_original_source_field()
 >}}}

 Thank you for your feedback. You are right. The `::
 get_wp_templates_author_text_field()` method will always return a string
 if the `::get_wp_templates_original_source_field()` method  returns one of
 the expected values: `theme`, `plugin`, `site`, or `user`.

 However, if `::get_wp_templates_original_source_field()` method is changed
 to return unexpected values, it poses a risk.

 I suggest that `::get_wp_templates_author_text_field()` should return a
 default value instead of relying on
 `::get_wp_templates_original_source_field()` to return predefined values.
 I explored that option in https://github.com/WordPress/wordpress-
 develop/pull/7000.

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


More information about the wp-trac mailing list