SproutCMS

This is the code documentation for the SproutCMS project

class Cron

Methods for initialising, recording the progress of, and finalising and cron scripts

Source code (24 results)

/sprout/config/routes.php   Highlighted file source

Line 126: $config['cron_job/run/([a-zA-Z0-9_]+)'] = 'CronJobController/run/$1';
Line 127: $config['cron_job/runJob'] = 'CronJobController/runJob';

/sprout/config/routes.php   Highlighted file source

Line 126: $config['cron_job/run/([a-zA-Z0-9_]+)'] = 'CronJobController/run/$1';
Line 127: $config['cron_job/runJob'] = 'CronJobController/runJob';

/sprout/Controllers/Admin/ActionLogAdminController.php   Highlighted file source

Line 24: use Sprout\Helpers\Cron;
Line 195: public function cronCleanup()
Line 197: Cron::start('Clean up action log');
Line 207: Cron::message("{$affected} ordinary record(s) deleted");
Line 220: Cron::message('Deleted file ' . $data['filename']);
Line 222: Cron::message('Failed to delete file ' . $data['filename']);
Line 228: Cron::message("{$num_deleted} stale file reference(s) deleted");
Line 230: Cron::success();

/sprout/Controllers/Admin/ActionLogAdminController.php   Highlighted file source

Line 24: use Sprout\Helpers\Cron;
Line 195: public function cronCleanup()
Line 197: Cron::start('Clean up action log');
Line 207: Cron::message("{$affected} ordinary record(s) deleted");
Line 220: Cron::message('Deleted file ' . $data['filename']);
Line 222: Cron::message('Failed to delete file ' . $data['filename']);
Line 228: Cron::message("{$num_deleted} stale file reference(s) deleted");
Line 230: Cron::success();

/sprout/Controllers/Admin/CronJobAdminController.php   Highlighted file source

Line 31: * Handles most processing for Cron Jobs
Line 33: class CronJobAdminController extends ListAdminController
Line 35: protected $controller_name = 'cron_job';
Line 36: protected $friendly_name = 'Cron Jobs';
Line 100: * UI for running cron jobs manually
Line 104: $jobs = Register::getAllCronJobs();
Line 120: $view = new View('sprout/admin/cron_job_manual_run');
Line 124: 'title' => 'Cron job manual run',
Line 131: * Manually runs a cron job
Line 139: Notification::error('You must select a cron job');
Line 140: Url::redirect('admin/extra/cron_job/manual_run');
Line 146: $jobs = Register::getCronJobs($sched);
Line 155: Notification::error('Specified cron job is not registered');
Line 156: Url::redirect('admin/extra/cron_job/manual_run');
Line 165: // Set up cron environment

/sprout/Controllers/Admin/CronJobAdminController.php   Highlighted file source

Line 31: * Handles most processing for Cron Jobs
Line 33: class CronJobAdminController extends ListAdminController
Line 35: protected $controller_name = 'cron_job';
Line 36: protected $friendly_name = 'Cron Jobs';
Line 100: * UI for running cron jobs manually
Line 104: $jobs = Register::getAllCronJobs();
Line 120: $view = new View('sprout/admin/cron_job_manual_run');
Line 124: 'title' => 'Cron job manual run',
Line 131: * Manually runs a cron job
Line 139: Notification::error('You must select a cron job');
Line 140: Url::redirect('admin/extra/cron_job/manual_run');
Line 146: $jobs = Register::getCronJobs($sched);
Line 155: Notification::error('Specified cron job is not registered');
Line 156: Url::redirect('admin/extra/cron_job/manual_run');
Line 165: // Set up cron environment

/sprout/Controllers/Admin/FileAdminController.php   Highlighted file source

Line 29: use Sprout\Helpers\Cron;
Line 998: * They are removed later, when the deletion log is cleared; see {@see ActionLogAdminController::cronCleanup}.
Line 1209: * Does file cleanup - wrapper (cron)
Line 1211: public function cronCleanupInvalid()
Line 1213: Cron::start('Cleanup invalid files');
Line 1215: Cron::success();
Line 1248: Cron::message("Deleted file: " . json_encode($file));

/sprout/Controllers/Admin/FileAdminController.php   Highlighted file source

Line 29: use Sprout\Helpers\Cron;
Line 998: * They are removed later, when the deletion log is cleared; see {@see ActionLogAdminController::cronCleanup}.
Line 1209: * Does file cleanup - wrapper (cron)
Line 1211: public function cronCleanupInvalid()
Line 1213: Cron::start('Cleanup invalid files');
Line 1215: Cron::success();
Line 1248: Cron::message("Deleted file: " . json_encode($file));

/sprout/Controllers/Admin/PageAdminController.php   Highlighted file source

Line 34: use Sprout\Helpers\Cron;
Line 2375: public function cronPageActivate()
Line 2377: Cron::start('Activate pages');
Line 2389: Cron::message("Launching revision {$row['id']} on page {$row['page_id']}");
Line 2406: return Cron::failure('Database error');
Line 2411: Cron::success();
Line 2418: public function cronPageDeactivate()
Line 2420: Cron::start('De-activate pages');
Line 2435: Cron::message("De-activating page {$row['id']}");
Line 2445: return Cron::failure('Database error');
Line 2450: Cron::success();
Line 2608: * Cron version of the link checker
Line 2610: public function cronLinkChecker()
Line 2612: Cron::start('Link Checker');
Line 2614: Cron::success();
Line 2619: * Check for stale page content and send emails regarding stale pages; to be run via cron
Line 2623: public function cronCheckStale()
Line 2625: Cron::start('Stale page checker');
Line 2648: Cron::message('No stale pages found');
Line 2649: Cron::success();
Line 2698: Cron::message($msg);
Line 2716: Cron::message("Marking pages as sent");
Line 2723: Cron::message(Inflector::numPlural($count, 'page') . " marked as sent");
Line 2725: Cron::success();

/sprout/Controllers/Admin/PageAdminController.php   Highlighted file source

Line 34: use Sprout\Helpers\Cron;
Line 2375: public function cronPageActivate()
Line 2377: Cron::start('Activate pages');
Line 2389: Cron::message("Launching revision {$row['id']} on page {$row['page_id']}");
Line 2406: return Cron::failure('Database error');
Line 2411: Cron::success();
Line 2418: public function cronPageDeactivate()
Line 2420: Cron::start('De-activate pages');
Line 2435: Cron::message("De-activating page {$row['id']}");
Line 2445: return Cron::failure('Database error');
Line 2450: Cron::success();
Line 2608: * Cron version of the link checker
Line 2610: public function cronLinkChecker()
Line 2612: Cron::start('Link Checker');
Line 2614: Cron::success();
Line 2619: * Check for stale page content and send emails regarding stale pages; to be run via cron
Line 2623: public function cronCheckStale()
Line 2625: Cron::start('Stale page checker');
Line 2648: Cron::message('No stale pages found');
Line 2649: Cron::success();
Line 2698: Cron::message($msg);
Line 2716: Cron::message("Marking pages as sent");
Line 2723: Cron::message(Inflector::numPlural($count, 'page') . " marked as sent");
Line 2725: Cron::success();

/sprout/Controllers/AdminController.php   Highlighted file source

Line 38: use Sprout\Helpers\Cron;
Line 2230: public function cronGenericActivate()
Line 2232: Cron::start('Generic autolaunch system');
Line 2268: Cron::message("Processing table {$tbl}");
Line 2286: Cron::message("Activating record {$row['id']}");
Line 2301: Cron::message("Expiring record {$row['id']}");
Line 2305: return Cron::failure('Database error');
Line 2311: Cron::success();

/sprout/Controllers/AdminController.php   Highlighted file source

Line 38: use Sprout\Helpers\Cron;
Line 2230: public function cronGenericActivate()
Line 2232: Cron::start('Generic autolaunch system');
Line 2268: Cron::message("Processing table {$tbl}");
Line 2286: Cron::message("Activating record {$row['id']}");
Line 2301: Cron::message("Expiring record {$row['id']}");
Line 2305: return Cron::failure('Database error');
Line 2311: Cron::success();

/sprout/Controllers/ContentSubscribeController.php   Highlighted file source

Line 21: use Sprout\Helpers\Cron;
Line 152: public function cronSendSubscriptions()
Line 154: Cron::start("Content subscribe");
Line 156: Cron::message('Fetching subscriptions');
Line 162: Cron::message('');
Line 163: Cron::message('');
Line 164: Cron::message('Subscriptions for subsite: ' . $subsite['name']);
Line 182: Cron::message('Loading lists');
Line 209: Cron::message(" Loading '{$class}' failed: {$ex->getMessage()}");
Line 223: Cron::message(" Loading '{$class}' failed: {$ex->getMessage()}");
Line 227: Cron::message(" Loaded '{$class}'; Key '{$key}'; Num rows: " . count($result));
Line 240: Cron::message('');
Line 241: Cron::message('Building user lists');
Line 245: Cron::message('Num users: ' . count($users));
Line 246: Cron::message('');
Line 288: Cron::message($email . ($result ? '; success' : '; failure'));
Line 295: Cron::failure('All emails we tried to send failed; is there a server config error?');
Line 299: Cron::message('');
Line 302: Cron::message('');
Line 303: Cron::message('No items: ' . $none);
Line 304: Cron::message('Success: ' . $success);
Line 305: Cron::message('Failed: ' . $failure);
Line 307: Cron::success();

/sprout/Controllers/ContentSubscribeController.php   Highlighted file source

Line 21: use Sprout\Helpers\Cron;
Line 152: public function cronSendSubscriptions()
Line 154: Cron::start("Content subscribe");
Line 156: Cron::message('Fetching subscriptions');
Line 162: Cron::message('');
Line 163: Cron::message('');
Line 164: Cron::message('Subscriptions for subsite: ' . $subsite['name']);
Line 182: Cron::message('Loading lists');
Line 209: Cron::message(" Loading '{$class}' failed: {$ex->getMessage()}");
Line 223: Cron::message(" Loading '{$class}' failed: {$ex->getMessage()}");
Line 227: Cron::message(" Loaded '{$class}'; Key '{$key}'; Num rows: " . count($result));
Line 240: Cron::message('');
Line 241: Cron::message('Building user lists');
Line 245: Cron::message('Num users: ' . count($users));
Line 246: Cron::message('');
Line 288: Cron::message($email . ($result ? '; success' : '; failure'));
Line 295: Cron::failure('All emails we tried to send failed; is there a server config error?');
Line 299: Cron::message('');
Line 302: Cron::message('');
Line 303: Cron::message('No items: ' . $none);
Line 304: Cron::message('Success: ' . $success);
Line 305: Cron::message('Failed: ' . $failure);
Line 307: Cron::success();

/sprout/Controllers/CronJobController.php   Highlighted file source

Line 23: * Runs scheduled tasks assigned by {@see Register::cronJob} on behalf of the UN*X cron utility
Line 25: class CronJobController extends Controller
Line 31: die('Cron jobs must be run via CLI');
Line 34: $_ENV['CRON'] = 1;
Line 39: * Run a given cron schedule
Line 45: * @param string $schedule Cron job schedule, e.g. 'daily' or 'weekly'
Line 50: $jobs = Register::getCronJobs($schedule);
Line 62: $cmd = implode(' ', [$php, $script, 'cron_job/runJob', $class, $func, '2>&1']);
Line 106: * Internal job runner for cron jobs

/sprout/Controllers/CronJobController.php   Highlighted file source

Line 23: * Runs scheduled tasks assigned by {@see Register::cronJob} on behalf of the UN*X cron utility
Line 25: class CronJobController extends Controller
Line 31: die('Cron jobs must be run via CLI');
Line 34: $_ENV['CRON'] = 1;
Line 39: * Run a given cron schedule
Line 45: * @param string $schedule Cron job schedule, e.g. 'daily' or 'weekly'
Line 50: $jobs = Register::getCronJobs($schedule);
Line 62: $cmd = implode(' ', [$php, $script, 'cron_job/runJob', $class, $func, '2>&1']);
Line 106: * Internal job runner for cron jobs

/sprout/Controllers/DbToolsController.php   Highlighted file source

Line 96: [ 'url' => 'admin/extra/cron_job/manual_run', 'name' => 'Manual run cron job', 'desc' => 'Manually run a cron job in a browser' ],
Line 117: [ 'url' => 'admin/intro/cron_job', 'name' => 'Cron job log', 'desc' => 'Cron (scheduled task) log' ],
Line 2111: // Handle common acronyms

/sprout/Controllers/DbToolsController.php   Highlighted file source

Line 96: [ 'url' => 'admin/extra/cron_job/manual_run', 'name' => 'Manual run cron job', 'desc' => 'Manually run a cron job in a browser' ],
Line 117: [ 'url' => 'admin/intro/cron_job', 'name' => 'Cron job log', 'desc' => 'Cron (scheduled task) log' ],
Line 2111: // Handle common acronyms

/sprout/Helpers/Constants.php   Highlighted file source

Line 36: /** Cron and workers - job status */
Line 200: 'cart', 'config', 'content_block', 'captcha', 'category', 'content_subscribe', 'cron_job',

/sprout/Helpers/Constants.php   Highlighted file source

Line 36: /** Cron and workers - job status */
Line 200: 'cart', 'config', 'content_block', 'captcha', 'category', 'content_subscribe', 'cron_job',

/sprout/Helpers/Cron.php   Highlighted file source

Line 20: * Methods for initialising, recording the progress of, and finalising and cron scripts
Line 22: class Cron
Line 31: * Called at the beginning of a cron job.
Line 44: // the CronJobAdminController's UI but it's possible to call the methods directly
Line 47: $_ENV['CRON'] = 1;
Line 55: set_exception_handler(array('Sprout\\Helpers\\Cron', 'exceptionHandler'));
Line 56: register_shutdown_function(array('Sprout\\Helpers\\Cron', 'shutdown'));
Line 65: self::$job_id = Pdb::insert('cron_jobs', $update_fields);
Line 71: $q = "UPDATE {$pf}cron_jobs
Line 85: * Save and output log message for the currently running cron job
Line 118: * Report that a cron job failed.
Line 129: $q = "UPDATE {$pf}cron_jobs SET
Line 136: echo 'Cron job failed. See log entry #' . self::$job_id . ' for more info';
Line 142: * Report the successful completion of the cron job.
Line 150: $q = "UPDATE {$pf}cron_jobs SET
Line 162: * Exception and error handling for CRON jobs

/sprout/Helpers/Register.php   Highlighted file source

Line 44: private static $cron_jobs = [];
Line 535: * Register a method to be called for cron job processing
Line 538: * another schedule by duplicating the cron_daily.sh file and making the new
Line 542: * Register::cronJob('daily', 'Sprout\\Controllers\\Admin\\PageAdminController', 'cronPageActivate');
Line 545: * e.g. 'daily' will be called by the request 'cron_job/run/daily'
Line 546: * @param string $class The class containing the cron job method. Must be a controller
Line 549: public static function cronJob($schedule, $class, $func)
Line 551: if (!isset(self::$cron_jobs[$schedule])) {
Line 552: self::$cron_jobs[$schedule] = [];
Line 554: self::$cron_jobs[$schedule][] = [$class, $func];
Line 559: * Return the methods for a given cron job schedule
Line 564: public static function getCronJobs($schedule)
Line 566: return @self::$cron_jobs[$schedule] ?: [];
Line 571: * Return all registered cron jobs
Line 573: * @return array Key is schedule, and array is a list of jobs like {@see Register::getCronJobs}
Line 575: public static function getAllCronJobs()
Line 577: return self::$cron_jobs;

/sprout/Helpers/Register.php   Highlighted file source

Line 44: private static $cron_jobs = [];
Line 535: * Register a method to be called for cron job processing
Line 538: * another schedule by duplicating the cron_daily.sh file and making the new
Line 542: * Register::cronJob('daily', 'Sprout\\Controllers\\Admin\\PageAdminController', 'cronPageActivate');
Line 545: * e.g. 'daily' will be called by the request 'cron_job/run/daily'
Line 546: * @param string $class The class containing the cron job method. Must be a controller
Line 549: public static function cronJob($schedule, $class, $func)
Line 551: if (!isset(self::$cron_jobs[$schedule])) {
Line 552: self::$cron_jobs[$schedule] = [];
Line 554: self::$cron_jobs[$schedule][] = [$class, $func];
Line 559: * Return the methods for a given cron job schedule
Line 564: public static function getCronJobs($schedule)
Line 566: return @self::$cron_jobs[$schedule] ?: [];
Line 571: * Return all registered cron jobs
Line 573: * @return array Key is schedule, and array is a list of jobs like {@see Register::getCronJobs}
Line 575: public static function getAllCronJobs()
Line 577: return self::$cron_jobs;

/sprout/Helpers/WorkerCtrl.php   Highlighted file source

Line 80: // If this is called from within a cronjob, let the cron know
Line 81: if (isset($_ENV['CRON'])) {
Line 82: Cron::message("Starting worker job # {$job_id}, class '{$class_name}'.");

A total of 255 lines in 24 files were found