[wp-trac] [WordPress Trac] #40176: Filter user_trailingslashit called with inconsistent $type_of_string for Post-Tags

WordPress Trac noreply at wordpress.org
Thu Mar 16 22:32:06 UTC 2017


#40176: Filter user_trailingslashit called with inconsistent $type_of_string for
Post-Tags
---------------------------+-----------------------------
 Reporter:  Andi Dittrich  |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Permalinks     |    Version:  4.7.3
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 It seems to be a general inconsistency issue with the handling of post-
 tags in combination with the user_trailingslashit function/filter.

 Assumption: `$type_of_string` should be consitent and of type **tag** or
 **post_tag**

 == Testcase ==

 Permalink Structure with Trailing-Slash:
 {{{
 /%year%/%monthnum%/%day%/%postname%/
 }}}

 === Testcode to produce debug output ===

 {{{#!php
 // disable canoncial redirects
 add_action('redirect_canonical', '__return_false');

 // show all events with tag/ urls
 add_filter('user_trailingslashit', function($string, $type_of_url){
   if (strpos($string, 'tag/') !== false){

      echo 'Tag Link: ', $string, ' of type ', $type_of_url, PHP_EOL;

   }
 }, 100, 2);
 }}}

 == Expected behaviour ==

 Outputs like **Tag Link: /tag/mytag1/ of type post_tag** everytimes the
 url is of type **Tag**

 == Current behaviour ==

 On Post Pages: **Tag Link: /tag/mytag1/ of type category** for related
 post-tag links
 On Canoncial Redirects: **Tag Link: /tag/mytag1/ of type category** AND
 **Tag Link: /tag/mytag1/ of type** (not set!)

 == Identified Issues ==

 **wp-includes/canoncial.php** line 425

 its not checked if current page if of type **tag**

 {{{#!php
 foreach ( array('single', 'category', 'page', 'day', 'month', 'year',
 'home') as $type ) {
 }}}

 **wp-includes/taxonomy.php** line 3882

 the `$type_of_string` variable is set to **category** by default instead
 of `$taxonomy`

 {{{#!php
 $termlink = home_url( user_trailingslashit($termlink, 'category') );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40176>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list