public/wordpress/wp-content/plugins/backupbuddy/classes/housekeeping.php
/* validate_bb_schedules_in_wp()
	 *
	 * Verifies schedules all exist and are set up as expected with proper interverals, etc.
	 *
	 */
validate_bb_schedules_in_wp()
Verifies schedules all exist and are set up as expected with proper interverals, etc.
validate_bb_schedules_in_wp () Verifies schedules all exist and are set up as expected with proper interverals etc .
public static function validate_bb_schedules_in_wp() {
		foreach ( pb_backupbuddy::$options['schedules'] as $schedule_id => $schedule ) {
			$cron_inverval = wp_get_schedule( 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int)$schedule_id ) ) );
			$intervals = wp_get_schedules();
			if ( FALSE === $cron_inverval ) { 
				$result = backupbuddy_core::schedule_event( $schedule['first_run'], $schedule['interval'], 'run_scheduled_backup', array( (int)$schedule_id ) ); 
				if ( $result === FALSE ) {
					$message = 'Error #83443784: A missing schedule was identified but unable to be re-created. Your schedule may not work properly & need manual attention.';
					pb_backupbuddy::alert( $message, true );
				} else {
					pb_backupbuddy::alert( 'Warning #2389373: A missing schedule was identified and re-created. This should have corrected any problem with this schedule.', true );
				}
				continue;
			}
			if ( $cron_inverval != $schedule['interval'] ) { 
				$cron_run = wp_next_scheduled( 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int)$schedule_id ) ) );
				$result = backupbuddy_core::unschedule_event( $cron_run, 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int)$schedule_id ) ) ); 
				if ( $result === FALSE ) {
					$message = 'Error removing invalid event from WordPress. Your schedule may not work properly. Please try again. Error #38279343. Check your BackupBuddy error log for details.';
					pb_backupbuddy::alert( $message, true );
					continue;
				}
				if ( 0 == $schedule['last_run'] ) {
					$next_run = $schedule['first_run'];
				} else {
					$next_run = (int)$schedule['last_run'] + (int)$intervals[ $schedule['interval'] ]['interval'];
				}
				$result = backupbuddy_core::schedule_event( $next_run, $schedule['interval'], 'run_scheduled_backup', array( (int)$schedule_id ) ); 
				if ( $result === FALSE ) {
					$message = 'Error #237836464: An invalid schedule with the incorrect interval was identified & deleted but unable to be re-created. Your schedule may not work properly & need manual attention.';
					pb_backupbuddy::alert( $message, true );
					continue;
				} else {
					pb_backupbuddy::alert( 'Warning #2423484: An invalid schedule with the incorrect interval was identified and updated. This should have corrected any problem with this schedule.', true );
				}
			}
		} 
	}
public static function validate_bb_schedules_in_wp ( ) { foreach ( pb_backupbuddy :: $ options [ 'schedules' ] as $ schedule_id => $ schedule ) { $ cron_inverval = wp_get_schedule ( 'backupbuddy_cron' , array ( 'run_scheduled_backup' , array ( ( int ) $ schedule_id ) ) ) ; $ intervals = wp_get_schedules ( ) ; if ( FALSE === $ cron_inverval ) { $ result = backupbuddy_core :: schedule_event ( $ schedule [ 'first_run' ] , $ schedule [ 'interval' ] , 'run_scheduled_backup' , array ( ( int ) $ schedule_id ) ) ; if ( $ result === FALSE ) { $ message = 'Error #83443784: A missing schedule was identified but unable to be re-created. Your schedule may not work properly & need manual attention.' ; pb_backupbuddy :: alert ( $ message , true ) ; } else { pb_backupbuddy :: alert ( 'Warning #2389373: A missing schedule was identified and re-created. This should have corrected any problem with this schedule.' , true ) ; } continue ; } if ( $ cron_inverval != $ schedule [ 'interval' ] ) { $ cron_run = wp_next_scheduled ( 'backupbuddy_cron' , array ( 'run_scheduled_backup' , array ( ( int ) $ schedule_id ) ) ) ; $ result = backupbuddy_core :: unschedule_event ( $ cron_run , 'backupbuddy_cron' , array ( 'run_scheduled_backup' , array ( ( int ) $ schedule_id ) ) ) ; if ( $ result === FALSE ) { $ message = 'Error removing invalid event from WordPress. Your schedule may not work properly. Please try again. Error #38279343. Check your BackupBuddy error log for details.' ; pb_backupbuddy :: alert ( $ message , true ) ; continue ; } if ( 0 == $ schedule [ 'last_run' ] ) { $ next_run = $ schedule [ 'first_run' ] ; } else { $ next_run = ( int ) $ schedule [ 'last_run' ] + ( int ) $ intervals [ $ schedule [ 'interval' ] ] [ 'interval' ] ; } $ result = backupbuddy_core :: schedule_event ( $ next_run , $ schedule [ 'interval' ] , 'run_scheduled_backup' , array ( ( int ) $ schedule_id ) ) ; if ( $ result === FALSE ) { $ message = 'Error #237836464: An invalid schedule with the incorrect interval was identified & deleted but unable to be re-created. Your schedule may not work properly & need manual attention.' ; pb_backupbuddy :: alert ( $ message , true ) ; continue ; } else { pb_backupbuddy :: alert ( 'Warning #2423484: An invalid schedule with the incorrect interval was identified and updated. This should have corrected any problem with this schedule.' , true ) ; } } } }
validate_bb_schedules_in_wp()
 Verifies schedules all exist and are set up as expected with proper interverals, etc.
validate_bb_schedules_in_wp () Verifies schedules all exist and are set up as expected with proper interverals etc .
// Loop through each BB schedule and create WP schedule to match. // Retrieve current interval WordPress cron thinks the schedule is at. // Schedule MISSING. Re-schedule. // Add new schedule. // Schedule exists BUT interval is WRONG. Fix it. // Delete existing schedule. // Determine when the next run time SHOULD be. // Add new schedule. // end foreach.