[wp-trac] [WordPress Trac] #43860: Dead code in feed_links_extra()

WordPress Trac noreply at wordpress.org
Thu Apr 26 07:37:42 UTC 2018


#43860: Dead code in feed_links_extra()
-------------------------+-----------------------
 Reporter:  dmenard      |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  5.0
Component:  Feeds        |     Version:  3.7
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  template
-------------------------+-----------------------
Changes (by dmenard):

 * keywords:  needs-patch => has-patch


Comment:

 Hello @desrosj,

 Thanks for the kind words!

 > we need to make sure something was not left behind in the new
 conditional

 There are some differences between the old clause and the new one:

 * **post type object:** the old clause was using
 {{{get_queried_object()}}} to get the post type object. The new clause
 uses {{{get_query_var( 'post_type' )}}} and keeps only the first value if
 there are many ones.
 * **feed title:** the old clause was using {{{post_type_archive_title()}}}
 (which can be filtered) to construct the feed title. The new clause calls
 directly {{{$post_type_obj->labels->name}}}.
 * **return value:** the old clause was creating a feed link only if we got
 a valid queried object. There are no checks in the new clause: we use
 directly the query var, call {{{get_post_type_object()}}} (which can
 return null) and always generate a feed by calling
 {{{get_post_type_archive_feed_link( $post_type_obj->name )}}} (will
 generate a warning and an empty href if the post type is not valid). But
 perhaps the post_type query var is validated elsewhere during the query
 parsing?

 So, it's not the same...

 However, if the modification was introduced in r25291 as you found, it
 means that the old code has not been executed for more than five years. So
 I presume the new code is ok?..

 > Are you interested in creating a patch for this?

 For now, I've added a diff attachment wich removes the duplicate elseif
 clause in {{{feed_links_extra()}}} and does nothing else.

 As I haven't used trac for years, this is a git diff (I followed the
 guidelines of [https://make.wordpress.org/core/handbook/contribute/git/
 the handbook]).

 I hope it's ok, please let me know.

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


More information about the wp-trac mailing list