Permalink
Browse files

Changes for email notification about error and timeout scheduled tasks

  • Loading branch information...
yurabakhtin committed Jun 18, 2018
1 parent 2caf042 commit 0cb334e9bc4d7183315829271d07bd82e5068f83
View
@@ -445,15 +445,11 @@ function detect_timeout_cron_jobs( $error_task = NULL )
WHERE clog_ctsk_ID IN ( '.$DB->quote( array_keys( $tasks ) ).' )', 'Mark timeouts in cron jobs.' );
}
if( !is_null( $error_task ) )
{ // Send notification with error task
$tasks[ $error_task['ID'] ] = $error_task;
}
if( count( $tasks ) > 0 )
{ // Send notification email about timed out and error cron jobs to users with edit options permission
if( count( $tasks ) > 0 || $error_task !== NULL )
{ // Send notification email about timed out and error cron jobs to users with edit options permission:
$email_template_params = array(
'tasks' => $tasks,
'timeout_tasks' => $tasks,
'error_task' => $error_task,
);
send_admin_notification( NT_('Scheduled task error'), 'scheduled_task_error_report', $email_template_params );
}
@@ -14,20 +14,30 @@
emailskin_include( '_email_header.inc.html.php', $params );
// ------------------------------- END OF EMAIL HEADER --------------------------------
global $admin_url, $baseurl;
global $admin_url;
// Default params:
$params = array_merge( array(
'tasks' => array(),
'timeout_tasks' => array(),
'error_task' => NULL,
), $params );
echo '<p'.emailskin_style( '.p' ).'>'.T_('The following scheduled tasks have ended with error:')."</p>\n";
if( is_array( $params['tasks'] ) && count( $params['tasks'] ) )
{
if( $params['error_task'] !== NULL )
{ // Display an error task:
echo '<p'.emailskin_style( '.p' ).'>'.T_('The following scheduled task has ended with an error:')."</p>\n";
echo '<p'.emailskin_style( '.p' ).'>';
echo '<b>'.$params['error_task']['name'].'</b> ('.get_link_tag( $admin_url.'?ctrl=crontab&action=view&cjob_ID='.$params['error_task']['ID'], '#'.$params['error_task']['ID'], '.a' ).'):<br>';
echo str_replace( "\n", '<br>', ltrim( $params['error_task']['message'], "\n" ) );
echo "</p>\n";
}
if( is_array( $params['timeout_tasks'] ) && count( $params['timeout_tasks'] ) )
{ // Display timeout tasks:
echo '<p'.emailskin_style( '.p' ).'>'.T_('The following scheduled tasks have timed out:')."</p>\n";
echo '<p'.emailskin_style( '.p' ).'><ul>';
foreach( $params['tasks'] as $task_ID => $task )
foreach( $params['timeout_tasks'] as $task_ID => $task )
{
echo '<li>'.$task['name'].' (#'.$task_ID.'):<br>'.str_replace( "\n", '<br>', T_( $task['message'] ) ).'</li>';
echo '<li><b>'.$task['name'].'</b> ('.get_link_tag( $admin_url.'?ctrl=crontab&action=view&cjob_ID='.$task_ID, '#'.$task_ID, '.a' ).'):<br>'.str_replace( "\n", '<br>', T_( $task['message'] ) ).'</li>';
}
echo "</ul></p>\n";
}
@@ -14,19 +14,28 @@
emailskin_include( '_email_header.inc.txt.php', $params );
// ------------------------------- END OF EMAIL HEADER --------------------------------
global $admin_url, $baseurl;
global $admin_url;
// Default params:
$params = array_merge( array(
'tasks' => array(),
'timeout_tasks' => array(),
'error_task' => NULL,
), $params );
echo T_('The following scheduled tasks have ended with error:')."\n";
if( is_array( $params['tasks'] ) && count( $params['tasks'] ) )
{
foreach( $params['tasks'] as $task_ID => $task )
if( $params['error_task'] !== NULL )
{ // Display an error task:
echo T_('The following scheduled task has ended with an error:')."\n";
echo $params['error_task']['name'].' (#'.$params['error_task']['ID'].' - '.$admin_url.'?ctrl=crontab&action=view&cjob_ID='.$params['error_task']['ID'].'):'."\n";
echo ltrim( $params['error_task']['message'], "\n" );
echo "\n\n";
}
if( is_array( $params['timeout_tasks'] ) && count( $params['timeout_tasks'] ) )
{ // Display timeout tasks:
echo T_('The following scheduled tasks have timed out:')."\n";
foreach( $params['timeout_tasks'] as $task_ID => $task )
{
echo '- '.$task['name'].' (#'.$task_ID.'):'."\n".T_( $task['message'] )."\n";
echo '- '.$task['name'].' (#'.$task_ID.' - '.$admin_url.'?ctrl=crontab&action=view&cjob_ID='.$task_ID.'):'."\n".T_( $task['message'] )."\n";
}
}
echo "\n";

0 comments on commit 0cb334e

Please sign in to comment.