[wp-trac] [WordPress Trac] #13391: wpmu-terms.php fails if there are more terms in the blog's terms table than there are in wp_sitecategories

WordPress Trac wp-trac at lists.automattic.com
Fri May 14 13:07:06 UTC 2010


#13391: wpmu-terms.php fails if there are more terms in the blog's terms table than
there are in wp_sitecategories
----------------------------+-----------------------------------------------
 Reporter:  mkanat          |       Owner:            
     Type:  defect (bug)    |      Status:  new       
 Priority:  normal          |   Milestone:  Unassigned
Component:  Administration  |     Version:  3.0       
 Severity:  major           |    Keywords:            
----------------------------+-----------------------------------------------
 fix_blog_terms in wpmu-terms does this:

 $maxterm = $wpdb->get_var( "SELECT max(cat_ID) FROM
 {$wpdb->sitecategories}" )

 Then later it does this:

 $term_id = $row->term_id + mt_rand( $maxterm+100, $maxterm+4000 );

 However, if there are thousands of terms in the blog's terms table, and
 only a few terms in wp_sitecategories, this will result in term_ids that
 conflict with other term_ids in $wpdb->terms.

 The simple (though probably not ideal) solution is to change the $maxterm
 line to:


         $maxterm = max($wpdb->get_var( "SELECT max(cat_ID) FROM
 {$wpdb->sitecategories}" ),
                        $wpdb->get_var( "SELECT max(cat_ID) FROM
 {$wpdb->terms}" ) );

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13391>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list