bb_upgrade_1080

The BuddyPress bb upgrade 1080 function.

Description

bb_upgrade_1080(); 

Usage

  1. if ( !function_exists( 'bb_upgrade_1080' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-admin/includes/functions.bb-upgrade.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bb_upgrade_1080(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-admin/includes/functions.bb-upgrade.php  
  1. function bb_upgrade_1080() { 
  2. global $bbdb, $wp_taxonomy_object; 
  3. if ( ( $dbv = bb_get_option_from_db( 'bb_db_version' ) ) && $dbv >= 1526 ) 
  4. return; 
  5.  
  6. $offset = 0; 
  7. while ( $tags = (array) $bbdb->get_results( "SELECT * FROM $bbdb->tags LIMIT $offset, 100" ) ) { 
  8. if ( !ini_get('safe_mode') ) set_time_limit(600); 
  9. $wp_taxonomy_object->defer_term_counting(true); 
  10. for ( $i = 0; isset($tags[$i]); $i++ ) { 
  11. $bbdb->insert( $bbdb->terms, array(  
  12. 'name' => $tags[$i]->raw_tag,  
  13. 'slug' => $tags[$i]->tag 
  14. ) ); 
  15. $term_id = $bbdb->insert_id; 
  16. $bbdb->insert( $bbdb->term_taxonomy, array( 
  17. 'term_id' => $term_id,  
  18. 'taxonomy' => 'bb_topic_tag',  
  19. 'description' => '' 
  20. ) ); 
  21. $term_taxonomy_id = $bbdb->insert_id; 
  22. $topics = (array) $bbdb->get_results( $bbdb->prepare( "SELECT user_id, topic_id FROM $bbdb->tagged WHERE tag_id = %d", $tags[$i]->tag_id ) ); 
  23. for ( $j = 0; isset($topics[$j]); $j++ ) { 
  24. $bbdb->insert( $bbdb->term_relationships, array( 
  25. 'object_id' => $topics[$j]->topic_id,  
  26. 'term_taxonomy_id' => $term_taxonomy_id,  
  27. 'user_id' => $topics[$j]->user_id 
  28. ) ); 
  29. $wp_taxonomy_object->update_term_count( array( $term_taxonomy_id ), 'bb_topic_tag' ); 
  30. $wp_taxonomy_object->defer_term_counting(false); 
  31. $offset += 100; 
  32.  
  33. bb_update_option( 'bb_db_version', 1526 ); 
  34.  
  35. return 'Tags copied to taxonomy tables: ' . __FUNCTION__;