[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:59:07 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:  6.7
Component:  REST API                     |     Version:  trunk
 Severity:  minor                        |  Resolution:
 Keywords:  has-patch changes-requested  |     Focuses:  rest-api
-----------------------------------------+-----------------------
Changes (by hellofromTonya):

 * keywords:  has-patch => has-patch changes-requested
 * milestone:  Awaiting Review => 6.7


Comment:

 Hmm, this is interesting.

 `WP_REST_Templates_Controller:: get_wp_templates_original_source_field()`
 always returns a `string` with one of the values used within the
 `switch()` within
 `WP_REST_Templates_Controller::get_wp_templates_author_text_field()`.

 But as @antonvlasenko noted, what if either method gets changed? To make
 the code more future-proof to avoid changes in one method affecting the
 other, a default of an empty string could be the graceful fall-through,
 e.g. `return '';'` at the end of the method.

 Moving this into 6.7 for visibility.

 I'll also comment on the PR with a suggested change.

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


More information about the wp-trac mailing list