bb_upgrade_1010

The BuddyPress bb upgrade 1010 function.

Description

bb_upgrade_1010(); 

Usage

  1. if ( !function_exists( 'bb_upgrade_1010' ) ) { 
  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_1010(); 
  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_1010() { 
  2. global $bbdb; 
  3. if ( ( $dbv = bb_get_option_from_db( 'bb_db_version' ) ) && $dbv >= 952 ) 
  4. return; 
  5.  
  6. $forums = (array) $bbdb->get_results( "SELECT forum_id, forum_parent FROM $bbdb->forums" ); 
  7. $forum_ids = (array) $bbdb->get_col( '', 0 ); 
  8.  
  9. foreach ( $forums as $forum ) { 
  10. if ( $forum->forum_parent && !in_array( $forum->forum_parent, $forum_ids ) ) 
  11. $bbdb->query( "UPDATE $bbdb->forums SET forum_parent = 0 WHERE forum_id = '$forum->forum_id'" ); 
  12.  
  13. bb_update_option( 'bb_db_version', 952 ); 
  14.  
  15. return 'Done re-parenting orphaned forums: ' . __FUNCTION__;