[wp-trac] [WordPress Trac] #39308: Invalid taxonomy error in WP 4.7

WordPress Trac noreply at wordpress.org
Fri Dec 16 20:12:40 UTC 2016


#39308: Invalid taxonomy error in WP 4.7
--------------------------+------------------------------
 Reporter:  wpfo          |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  4.7
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------
Changes (by wpfo):

 * keywords:  reporter-feedback =>


Comment:

 Hey swissspidy,
 You are wrong!

 >It's worth noting that the `name` is being set in the constructor
 > (`WP_Taxonomy::__construct()`). There's no need to set it again in
 > `WP_Taxonomy::set_props()` because it's already there. If there's a
 > problem it's probably somewhere else.

 1)
 'name' is setted in __construct() of WP_Taxonomy from field $taxonomy
 $this->name = $taxonomy;

 2)
 In function 'set_props()' $this->name is setted (resetted) again from
 $args 'name'
 if 'name' in $args exists and 'name' in $args is '', in this code block:
 {{{#!php
 <?php
 foreach ( $args as $property_name => $property_value ) {
         $this->$property_name = $property_value;
 }

 }}}

 And I haven't said to set it again, but to set ($args['name'] =
 $this->name);
 to avoid that $this->name would be reseted;

 Also solution (as posted) should work well:
 {{{#!php
 <?php
 $args['name'] = $this->name;//There is no reason not to have this. Why
 this was removed?

 foreach ( $args as $property_name => $property_value ) {
         $this->$property_name = $property_value;
 }

 }}}


 >It's worth noting that the 'More Taxonomies' plugin hasn't been updated
 in
 > over 5 years and directly modifies the `$wp_taxonomies` global. Are
 there
 > any other plugins where this happens? Some sample code to reproduce
 would
 > be nice.
 Plugin 'More Taxonomies' has over 2000 Active Installs.

 To reproduce it:
 1)
 Install that plugin and create a taxonomy e.g for post_type 'post'.

 2)
 Or Create a taxonomy in code and set 'name' -> '' in $args

 >Ps. The `has-patch` keyword is only for when there's a patch file
 attached
 > to a ticket.
 I don't see Keyword has-solution.

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


More information about the wp-trac mailing list