本文整理汇总了PHP中spawn_cron函数的典型用法代码示例。如果您正苦于以下问题:PHP spawn_cron函数的具体用法?PHP spawn_cron怎么用?PHP spawn_cron使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spawn_cron函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register_cron
function register_cron($run_immediately = false)
{
if ($this->check_cron_registered()) {
$this->unregister_cron();
}
wp_schedule_event($this->o['cron_time'], $this->o['refresh_period'], $this->cron_event);
if ($run_immediately) {
spawn_cron();
}
}
示例2: handle_subscription
private function handle_subscription()
{
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
Header('Content-Type: text/plain');
$this->send_text('200 OK', $_GET['hub_challenge']);
} else {
wp_schedule_single_event(time(), 'degg_instagram_fetch', array($this->client_id, $this->tag));
spawn_cron(time());
$this->send_text('200 OK', "OK");
}
}
示例3: cron_next_step
function cron_next_step($spawn_cron = true)
{
$this->status('details', 'Scheduling Cron for ' . $this->_backup['serial'] . '.');
$this->log('Scheduling Cron for ' . $this->_backup['serial'] . '.');
wp_schedule_single_event(time(), $this->_parent->_var . '-cron_process_backup', array($this->_backup['serial']));
if ($spawn_cron === true) {
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
}
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
}
示例4: runAt
/**
* Schedule a run at time "$time" unless a it's already scheduled or running
*
* @param integer $time Unix timestamp
* @param bool $forceRun If true, schedule a run regardless of whether it's already running and/or scheduled
* @param array $args
*
* @return bool
*/
function runAt($time, $forceRun = false, $args = array())
{
if ($forceRun || !$this->isScheduled()) {
if ($forceRun || !$this->isRunning()) {
$this->log->info("{$this->cronHook}: schedule at {$time}");
$this->timestamp = $time;
$this->args = $args;
wp_schedule_single_event($time, $this->cronHook, $args);
spawn_cron();
return true;
} else {
$this->log->info("{$this->cronHook}: schedule at {$time} but is already running");
}
} else {
$this->log->info("{$this->cronHook}: schedule at {$time} but is already scheduled");
}
return false;
}
示例5: start_cron
/**
* Kicks of an import or export cronjob.
*
* @param $type
*/
protected function start_cron($type)
{
update_option('_wpghs_' . $type . '_started', 'yes');
wp_schedule_single_event(time(), 'wpghs_' . $type . '');
spawn_cron();
}
示例6: wp_cron
function wp_cron() {
// Prevent infinite loops caused by lack of wp-cron.php
if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false )
return;
$crons = _get_cron_array();
if ( !is_array($crons) )
return;
$keys = array_keys( $crons );
if ( isset($keys[0]) && $keys[0] > time() )
return;
$schedules = wp_get_schedules();
foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > time() ) break;
foreach ( $cronhooks as $hook => $args ) {
if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
continue;
spawn_cron();
break 2;
}
}
}
示例7: send
//.........这里部分代码省略.........
pb_backupbuddy::status('details', 'Notifying Stash of completed multipart upload with done url `' . $done_url . '`.');
$request = new RequestCore($done_url);
$response = $request->send_request(true);
if (!$response->isOK()) {
$this_error = 'Error #756834682. Could not finalize Stash upload. Response code: `' . $response->get_response_code() . '`; Response body: `' . $response->get_response_body() . '`; Response headers: `' . $response->get_response_header() . '`.';
$pb_backupbuddy_destination_errors[] = $this_error;
pb_backupbuddy::status('error', $this_error);
return false;
} else {
// Good server response.
// See if we got an optional json response.
$upload_data = @json_decode($response->body, true);
if (isset($upload_data['error'])) {
$this_error = 'Stash error(s): `' . implode(' - ', $upload_data['error']) . '`.';
$pb_backupbuddy_destination_errors[] = $this_error;
pb_backupbuddy::status('error', $this_error);
return false;
}
pb_backupbuddy::status('details', 'Stash success sending file `' . basename($settings['_multipart_file']) . '`. File uploaded via multipart across `' . $this_part_number . '` parts and reported to Stash as completed.');
}
pb_backupbuddy::status('details', 'Stash has no more parts left for this multipart upload. Clearing multipart instance variables.');
$settings['_multipart_partnumber'] = 0;
$settings['_multipart_id'] = '';
$settings['_multipart_file'] = '';
$settings['_multipart_counts'] = array();
$settings['_multipart_upload_data'] = array();
}
delete_transient('pb_backupbuddy_stashquota_' . $settings['itxapi_username']);
// Delete quota transient since it probably has changed now.
// Schedule to continue if anything is left to upload for this multipart of any individual files.
if ($settings['_multipart_id'] != '' || count($files) > 0) {
pb_backupbuddy::status('details', 'Stash multipart upload has more parts left. Scheduling next part send.');
wp_schedule_single_event(time(), pb_backupbuddy::cron_tag('destination_send'), array($settings, $files, 'multipart', false));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
pb_backupbuddy::status('details', 'Stash scheduled send of next part(s). Done for this cycle.');
return array($settings['_multipart_id'], 'Sent ' . $this_part_number . ' of ' . count($multipart_destination_settings['_multipart_counts'] . ' parts.'));
}
}
// Upload each file.
foreach ($files as $file_id => $file) {
// Determine backup type directory (if zip).
$backup_type_dir = '';
$backup_type = '';
if (stristr($file, '.zip') !== false) {
// If a zip try to determine backup type.
pb_backupbuddy::status('details', 'Stash: Zip file. Detecting backup type if possible.');
$serial = pb_backupbuddy::$classes['core']->get_serial_from_file($file);
if (isset(pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'])) {
pb_backupbuddy::status('details', 'Stash: Detected backup type as `' . pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'] . '` via integrity check data.');
$backup_type_dir = pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'] . '/';
$backup_type = pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'];
} else {
if (stristr($file, '-db-') !== false) {
pb_backupbuddy::status('details', 'Stash: Detected backup type as `db` via filename.');
$backup_type_dir = 'db/';
$backup_type = 'db';
} elseif (stristr($file, '-full-') !== false) {
pb_backupbuddy::status('details', 'Stash: Detected backup type as `full` via filename.');
$backup_type_dir = 'full/';
$backup_type = 'full';
} else {
pb_backupbuddy::status('details', 'Stash: Could not detect backup type via integrity details nor filename.');
}
示例8: wp_cron
function wp_cron() {
$crons = _get_cron_array();
if ( !is_array($crons) )
return;
$keys = array_keys( $crons );
if ( isset($keys[0]) && $keys[0] > time() )
return;
$schedules = wp_get_schedules();
foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > time() ) break;
foreach ( $cronhooks as $hook => $args ) {
if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
continue;
spawn_cron();
break 2;
}
}
}
示例9: send
//.........这里部分代码省略.........
$dataRemains = false;
}
$isFileTest = false;
if (false !== stristr(basename($file), 'remote-send-test.php')) {
$isFileTest = true;
$settings['sendType'] = 'test';
}
if (true === $dataRemains) {
$isFileDone = false;
} else {
$isFileDone = true;
}
if (!isset($size)) {
$size = '';
}
pb_backupbuddy::status('details', 'Connecting to remote server to send data.');
$response = backupbuddy_remote_api::remoteCall($apiSettings, 'sendFile_' . $settings['sendType'], array(), $settings['max_time'], $file, $fileData, $prevPointer, $isFileTest, $isFileDone, $size, $filePath);
unset($fileData);
// Free up memory.
$settings['chunks_sent']++;
if (true === $dataRemains) {
// More chunks remain.
pb_backupbuddy::status('details', 'Connection finished sending part ' . $settings['chunks_sent'] . ' of ~' . $settings['chunks_total'] . '.');
} else {
// No more chunks remain.
pb_backupbuddy::status('details', 'Connection finished sending final part ' . $settings['chunks_sent'] . '.');
}
if (false === $response) {
echo implode(', ', backupbuddy_remote_api::getErrors()) . ' ';
pb_backupbuddy::status('error', 'Errors encountered details: ' . implode(', ', backupbuddy_remote_api::getErrors()));
global $pb_backupbuddy_destination_errors;
$pb_backupbuddy_destination_errors[] = backupbuddy_remote_api::getErrors();
return false;
//implode( ', ', backupbuddy_remote_api::getErrors() );
}
if (FALSE === ($prevPointer = ftell($fs))) {
pb_backupbuddy::status('error', 'Error #438347844: Unable to get ftell pointer of file handle for passing to prevPointer.');
@fclose($fs);
return false;
} else {
pb_backupbuddy::status('details', 'File pointer: `' . $prevPointer . '`.');
}
if (true === $dataRemains) {
// More data remains so see if we need to consider chunking to a new PHP process.
// If we are within X second of reaching maximum PHP runtime then stop here so that it can be picked up in another PHP process...
if (microtime(true) - self::$_timeStart + self::TIME_WIGGLE_ROOM >= $settings['max_time']) {
pb_backupbuddy::status('message', 'Approaching limit of available PHP chunking time of `' . $settings['max_time'] . '` sec. Ran for ' . round(microtime(true) - self::$_timeStart, 3) . ' sec. Proceeding to use chunking.');
@fclose($fs);
// Tells next chunk where to pick up.
$settings['resume_point'] = $prevPointer;
// Schedule cron.
$cronTime = time();
$cronArgs = array($settings, $files, $send_id, $delete_after);
$cronHashID = md5($cronTime . serialize($cronArgs));
$cronArgs[] = $cronHashID;
$schedule_result = backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
if (true === $schedule_result) {
pb_backupbuddy::status('details', 'Next Site chunk step cron event scheduled.');
} else {
pb_backupbuddy::status('error', 'Next Site chunk step cron even FAILED to be scheduled.');
}
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
return array($prevPointer, 'Sent part ' . $settings['chunks_sent'] . ' of ~' . $settings['chunks_total'] . ' parts.');
// filepointer location, elapsed time during the import
} else {
// End if.
pb_backupbuddy::status('details', 'Not approaching time limit.');
}
} else {
pb_backupbuddy::status('details', 'No more data remains (eg for chunking) so finishing up.');
}
}
// end while data remains in file.
// Update fileoptions stats.
pb_backupbuddy::status('details', 'About to load fileoptions data.');
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status('details', 'Fileoptions instance #20.');
$fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
if (true !== ($result = $fileoptions_obj->is_ok())) {
pb_backupbuddy::status('error', __('Fatal Error #9034.279327. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
return false;
}
pb_backupbuddy::status('details', 'Fileoptions data loaded.');
$fileoptions =& $fileoptions_obj->options;
$fileoptions['finish_time'] = microtime(true);
$fileoptions['status'] = 'success';
$fileoptions['_multipart_status'] = 'Sent all parts.';
if (isset($uploaded_speed)) {
$fileoptions['write_speed'] = $uploaded_speed;
}
$fileoptions_obj->save();
unset($fileoptions);
// Made it this far so completed!
pb_backupbuddy::status('message', 'Finished sending file. Took ' . round(microtime(true) - self::$_timeStart, 3) . ' seconds this round.');
pb_backupbuddy::status('deployFileSent', 'File sent.');
return true;
}
示例10: ScheduleReloadAttachments
/**
* Schedule the loading of attachments
*/
function ScheduleReloadAttachments()
{
wp_schedule_single_event(time(), 'wishlistmember_attachments_load');
spawn_cron(time());
}
示例11: _verb_getBackupStatus
private static function _verb_getBackupStatus()
{
$backupSerial = pb_backupbuddy::_POST('serial');
pb_backupbuddy::status('details', '*** End Remote Backup Log section', $backupSerial);
// Place at end of log.
backupbuddy_api::getBackupStatus($backupSerial);
// echos out. Use $returnRaw = true for remote_api call for this special verb that does not return json.
// Fix missing WP cron constant.
if (!defined('WP_CRON_LOCK_TIMEOUT')) {
define('WP_CRON_LOCK_TIMEOUT', 60);
// In seconds
}
// Try to force cron to run so that we can push the backup along.
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
}
示例12: ajax_remotesend
function ajax_remotesend()
{
wp_schedule_single_event(time(), 'pb_backupbuddy-cron_remotesend', array($_POST['destination_id'], $this->_options['backup_directory'] . $_POST['file']));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
echo 1;
die;
}
示例13: cron_next_step
function cron_next_step($spawn_cron = true, $future_offset = 0)
{
pb_backupbuddy::status('details', 'Scheduling Cron for `' . $this->_backup['serial'] . '`.');
// Need to make sure the database connection is active. Sometimes it goes away during long bouts doing other things -- sigh.
// This is not essential so use include and not require (suppress any warning)
pb_backupbuddy::status('details', 'Loading DB kicker in case database has gone away.');
@(include_once pb_backupbuddy::plugin_path() . '/lib/wpdbutils/wpdbutils.php');
if (class_exists('pluginbuddy_wpdbutils')) {
// This is the database object we want to use
global $wpdb;
// Get our helper object and let it use us to output status messages
$dbhelper = new pluginbuddy_wpdbutils($wpdb);
// If we cannot kick the database into life then signal the error and return false which will stop the backup
// Otherwise all is ok and we can just fall through and let the function return true
if (!$dbhelper->kick()) {
pb_backupbuddy::status('error', __('Database Server has gone away, unable to schedule next backup step. The backup cannot continue. This is most often caused by mysql running out of memory or timing out far too early. Please contact your host.', 'it-l10n-backupbuddy'));
pb_backupbuddy::status('action', 'halt_script');
// Halt JS on page.
return false;
} else {
pb_backupbuddy::status('details', 'Database seems to still be connected.');
}
} else {
// Utils not available so cannot verify database connection status - just notify
pb_backupbuddy::status('details', __('Database Server connection status unverified.', 'it-l10n-backupbuddy'));
}
// Schedule event.
$cron_time = time() + $future_offset;
$cron_tag = pb_backupbuddy::cron_tag('process_backup');
$cron_args = array($this->_backup['serial']);
pb_backupbuddy::status('details', 'Scheduling next step to run at `' . $cron_time . '` (localized time: ' . pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($cron_time)) . ') with cron tag `' . $cron_tag . '` and serial arguments `' . implode(',', $cron_args) . '`.');
$schedule_result = backupbuddy_core::schedule_single_event($cron_time, $cron_tag, $cron_args);
if ($schedule_result === false) {
pb_backupbuddy::status('error', 'Unable to schedule next cron step. Verify that another plugin is not preventing / conflicting.');
} else {
pb_backupbuddy::status('details', 'Next step scheduled.');
}
// Spawn cron.
if ($spawn_cron === true) {
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
}
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
pb_backupbuddy::status('details', 'About to run next step. If the backup stalls at this point then something is interfering with the WordPress CRON system such as a caching or scheduling plugin. Try disabling other plugins to see if it resolves issue. Check the Server Information page cron section to see if the next BackupBuddy step is scheduled to run. Enable "Classic" backup mode on the "Settings" page to rule out non-cron issues.');
return;
}
示例14: remote_send
public function remote_send()
{
if (defined('PB_DEMO_MODE')) {
die('Access denied in demo mode.');
}
if (pb_backupbuddy::_POST('send_importbuddy') == '1') {
$send_importbuddy = true;
} else {
$send_importbuddy = false;
}
wp_schedule_single_event(time(), pb_backupbuddy::cron_tag('remote_send'), array($_POST['destination_id'], pb_backupbuddy::$options['backup_directory'] . $_POST['file'], $_POST['trigger'], $send_importbuddy));
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
echo 1;
die;
}
示例15: send
//.........这里部分代码省略.........
$settings['_multipart_partnumber'] = 0;
$settings['_multipart_id'] = '';
$settings['_multipart_file'] = '';
$settings['_multipart_remotefile'] = '';
// Multipart completed so safe to prevent housekeeping of incomplete multipart uploads.
$settings['_multipart_transferspeeds'][] = $uploaded_speed;
// Overall upload speed average.
$uploaded_speed = array_sum($settings['_multipart_transferspeeds']) / count($settings['_multipart_counts']);
pb_backupbuddy::status('details', 'Upload speed average of all chunks: `' . pb_backupbuddy::$format->file_size($uploaded_speed) . '`.');
$settings['_multipart_counts'] = array();
// Update stats.
$fileoptions['_multipart_status'] = $update_status;
$fileoptions['finish_time'] = time();
$fileoptions['status'] = 'success';
if (isset($uploaded_speed)) {
$fileoptions['write_speed'] = $uploaded_speed;
}
$fileoptions_obj->save();
unset($fileoptions);
}
// Schedule to continue if anything is left to upload for this multipart of any individual files.
if ($settings['_multipart_id'] != '' || count($files) > 0) {
pb_backupbuddy::status('details', 'S3 multipart upload has more parts left. Scheduling next part send.');
$cronTime = time();
$cronArgs = array($settings, $files, $send_id, $delete_after);
$cronHashID = md5($cronTime . serialize($cronArgs));
$cronArgs[] = $cronHashID;
$schedule_result = backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
if (true === $schedule_result) {
pb_backupbuddy::status('details', 'Next S3 chunk step cron event scheduled.');
} else {
pb_backupbuddy::status('error', 'Next S3 chunk step cron even FAILED to be scheduled.');
}
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
update_option('_transient_doing_cron', 0);
// Prevent cron-blocking for next item.
return array($settings['_multipart_id'], 'Sent part ' . $this_part_number . ' of ' . count($settings['_multipart_counts']) . ' parts.');
}
}
// end if multipart continuation.
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
// Upload each file.
foreach ($files as $file_id => $file) {
// Determine backup type directory (if zip).
$backup_type_dir = '';
$backup_type = '';
if (stristr($file, '.zip') !== false) {
// If a zip try to determine backup type.
pb_backupbuddy::status('details', 'S3: Zip file. Detecting backup type if possible.');
$serial = backupbuddy_core::get_serial_from_file($file);
// See if we can get backup type from fileoptions data.
pb_backupbuddy::status('details', 'Fileoptions instance #9.');
$backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = true, $ignore_lock = true);
if (true !== ($result = $backup_options->is_ok())) {
pb_backupbuddy::status('error', 'Unable to open fileoptions file `' . backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' . '`.');
} else {
if (isset($backup_options->options['integrity']['detected_type'])) {
pb_backupbuddy::status('details', 'S3: Detected backup type as `' . $backup_options->options['integrity']['detected_type'] . '` via integrity check data.');
//$backup_type_dir = $backup_options->options['integrity']['detected_type'] . '/';
$backup_type = $backup_options->options['integrity']['detected_type'];
}
}
// If still do not know backup type then attempt to deduce it from filename.
if ($backup_type == '') {
if (stristr($file, '-db-') !== false) {