Merge branch 'MDL-65047-master' of git://github.com/lameze/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2019-03-27 22:30:18 +01:00
3 changed files with 32 additions and 37 deletions
+28 -3
View File
@@ -42,12 +42,37 @@ class portfolio_cron_task extends scheduled_task {
* Throw exceptions on errors (the job will be retried).
*/
public function execute() {
global $CFG;
global $CFG, $DB;
if ($CFG->enableportfolios) {
require_once($CFG->libdir . '/portfoliolib.php');
portfolio_cron();
require_once($CFG->libdir . '/portfolio/exporter.php');
if ($expired = $DB->get_records_select('portfolio_tempdata', 'expirytime < ?', [time()], '', 'id')) {
foreach ($expired as $tempdata) {
try {
$exporter = \portfolio_exporter::rewaken_object($tempdata->id);
$exporter->process_stage_cleanup(true);
} catch (\Exception $exception) {
mtrace('Exception thrown in portfolio cron while cleaning up ' . $tempdata->id . ': ' .
$exception->getMessage());
}
}
}
$process = $DB->get_records('portfolio_tempdata', ['queued' => 1], 'id ASC', 'id');
foreach ($process as $tempdata) {
try {
$exporter = \portfolio_exporter::rewaken_object($tempdata->id);
$exporter->process_stage_package();
$exporter->process_stage_send();
$exporter->save();
$exporter->process_stage_cleanup();
} catch (\Exception $exception) {
// This will get probably retried in the next cron until it is discarded by the code above.
mtrace('Exception thrown in portfolio cron while processing ' . $tempdata->id . ': ' .
$exception->getMessage());
}
}
}
}
}