public/wordpress/wp-content/plugins/backupbuddy/classes/core.php
/*	_calculate_tables()
	 *	
	 *	Takes a base level to calculate tables from.  Then adds additional tables.  Then removes any exclusions. Returns array of final table listing to backup.
	 *	
	 *	@see dump().
	 *	
	 *	@param		string		$base_dump_mode			Determines which database tables to dump by default. Valid values:  all, none, prefix
	 *	@param		array		$additional_includes	Array of additional table(s) to INCLUDE in dump. Added in addition to those found by the $base_dump_mode
	 *	@param		array		$additional_excludes	Array of additional table(s) to EXCLUDE from dump. Removed from those found by the $base_dump_mode + $additional_includes.
	 *	@return		array								Array of tables to backup.
	 */


Takes a base level to calculate tables from.  Then adds additional tables.  Then removes any exclusions. Returns array of final table listing to backup.



@param          string          $base_dump_mode                 Determines which database tables to dump by default. Valid values:  all, none, prefix
@param          array           $additional_includes    Array of additional table(s) to INCLUDE in dump. Added in addition to those found by the $base_dump_mode
@param          array           $additional_excludes    Array of additional table(s) to EXCLUDE from dump. Removed from those found by the $base_dump_mode + $additional_includes.
@return         array                                                           Array of tables to backup.
Takes a base level to calculate tables from . Then adds additional tables . Then removes any exclusions . Returns array of final table listing to backup . @param string $base_dump_mode Determines which database tables to dump by default . Valid values : all none prefix @param array $additional_includes Array of additional table ( s ) to INCLUDE in dump . Added in addition to those found by the $base_dump_mode @param array $additional_excludes Array of additional table ( s ) to EXCLUDE from dump . Removed from those found by the $base_dump_mode + $additional_includes . @return array Array of tables to backup .
public static function calculate_tables( $base_dump_mode, $additional_includes = array(), $additional_excludes = array() ) {
		global $wpdb;
		$wpdb->show_errors(); 
		$tables = array();
		pb_backupbuddy::status( 'details', 'Calculating mysql database tables to backup.' );
		pb_backupbuddy::status( 'details', 'Base database dump mode (before inclusions/exclusions): `' . $base_dump_mode . '`.' );
		if ( $base_dump_mode == 'all' ) { 
			$sql = 'SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE()';
			pb_backupbuddy::status( 'startAction', 'schemaTables' );
			$results = $wpdb->get_results( $sql, ARRAY_A );
			pb_backupbuddy::status( 'finishAction', 'schemaTables' );
			if ( ( null === $results ) || ( false === $results ) ) {
				pb_backupbuddy::status( 'error', 'Error #8493894a: Unable to calculate database tables with query: `' . $sql . '`. Check database permissions or contact host.' );
			}
			foreach( (array)$results as $result ) {
				array_push( $tables, $result['table_name'] );
			}
			unset( $results );
		} elseif ( $base_dump_mode == 'none' ) { 
		} elseif ( $base_dump_mode == 'prefix' ) { 
			pb_backupbuddy::status( 'details', 'Determining database tables with prefix `' . $wpdb->prefix . '`.' );
			$prefix_sql = str_replace( '_', '\_', $wpdb->prefix );
			$sql = "SELECT table_name FROM information_schema.tables WHERE table_name LIKE '{$prefix_sql}%' AND table_schema = DATABASE()";
			pb_backupbuddy::status( 'startAction', 'schemaTables' );
			$results = $wpdb->get_results( $sql, ARRAY_A );
			pb_backupbuddy::status( 'finishAction', 'schemaTables' );
			if ( ( null === $results ) || ( false === $results ) ) {
				pb_backupbuddy::status( 'error', 'Error #8493894b: Unable to calculate database tables with query: `' . $sql . '`. Check database permissions or contact host.' );
			}
			foreach( (array)$results as $result ) {
				array_push( $tables, $result['table_name'] );
			}
			unset( $results );
		} else { 
			pb_backupbuddy::status( 'error', 'Error #454545: Unknown database dump mode.' ); 
		}
		pb_backupbuddy::status( 'details', 'Base database tables based on settings (' . count( $tables ) . ' tables): `' . implode( ',', $tables ) . '`' );
		$tables = array_merge( $tables, $additional_includes );
		$tables = array_filter( $tables ); 
		pb_backupbuddy::status( 'details', 'Database tables after addition (' . count( $tables ) . ' tables): `' . implode( ',', $tables ) . '`' );
		$tables = array_diff( $tables, $additional_excludes );
		pb_backupbuddy::status( 'details', 'Database tables after exclusion (' . count( $tables ) . ' tables): `' . implode( ',', $tables ) . '`' );
		$tables = array_unique( $tables );
		return array_values( $tables ); 
	}
public static function calculate_tables ( $ base_dump_mode , $ additional_includes = array ( ) , $ additional_excludes = array ( ) ) { global $ wpdb ; $ wpdb -> show_errors ( ) ; $ tables = array ( ) ; pb_backupbuddy :: status ( 'details' , 'Calculating mysql database tables to backup.' ) ; pb_backupbuddy :: status ( 'details' , 'Base database dump mode (before inclusions/exclusions): `' . $ base_dump_mode . '`.' ) ; if ( $ base_dump_mode == 'all' ) { $ sql = 'SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE()' ; pb_backupbuddy :: status ( 'startAction' , 'schemaTables' ) ; $ results = $ wpdb -> get_results ( $ sql , ARRAY_A ) ; pb_backupbuddy :: status ( 'finishAction' , 'schemaTables' ) ; if ( ( null === $ results ) || ( false === $ results ) ) { pb_backupbuddy :: status ( 'error' , 'Error #8493894a: Unable to calculate database tables with query: `' . $ sql . '`. Check database permissions or contact host.' ) ; } foreach ( ( array ) $ results as $ result ) { array_push ( $ tables , $ result [ 'table_name' ] ) ; } unset ( $ results ) ; } elseif ( $ base_dump_mode == 'none' ) { } elseif ( $ base_dump_mode == 'prefix' ) { pb_backupbuddy :: status ( 'details' , 'Determining database tables with prefix `' . $ wpdb -> prefix . '`.' ) ; $ prefix_sql = str_replace ( '_' , '\_' , $ wpdb -> prefix ) ; $ sql = " SELECT table_name FROM information_schema.tables WHERE table_name LIKE ' { $ prefix_sql } %' AND table_schema = DATABASE() " ; pb_backupbuddy :: status ( 'startAction' , 'schemaTables' ) ; $ results = $ wpdb -> get_results ( $ sql , ARRAY_A ) ; pb_backupbuddy :: status ( 'finishAction' , 'schemaTables' ) ; if ( ( null === $ results ) || ( false === $ results ) ) { pb_backupbuddy :: status ( 'error' , 'Error #8493894b: Unable to calculate database tables with query: `' . $ sql . '`. Check database permissions or contact host.' ) ; } foreach ( ( array ) $ results as $ result ) { array_push ( $ tables , $ result [ 'table_name' ] ) ; } unset ( $ results ) ; } else { pb_backupbuddy :: status ( 'error' , 'Error #454545: Unknown database dump mode.' ) ; } pb_backupbuddy :: status ( 'details' , 'Base database tables based on settings (' . count ( $ tables ) . ' tables): `' . implode ( ',' , $ tables ) . '`' ) ; $ tables = array_merge ( $ tables , $ additional_includes ) ; $ tables = array_filter ( $ tables ) ; pb_backupbuddy :: status ( 'details' , 'Database tables after addition (' . count ( $ tables ) . ' tables): `' . implode ( ',' , $ tables ) . '`' ) ; $ tables = array_diff ( $ tables , $ additional_excludes ) ; pb_backupbuddy :: status ( 'details' , 'Database tables after exclusion (' . count ( $ tables ) . ' tables): `' . implode ( ',' , $ tables ) . '`' ) ; $ tables = array_unique ( $ tables ) ; return array_values ( $ tables ) ; }
_calculate_tables()
_calculate_tables ()
// Turn on error display. // Calculate base tables. // All tables in database to start with. // None to start with. // Do nothing. // Tables matching prefix. // unknown dump mode. // Should never see this. // Add additional tables. // Trim any phantom tables that the above line may have introduced. // Remove excluded tables. // Remove any duplicate tables. // Clean up indexing & return.