-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add system status warning to display scheduled job failures #21762
Conversation
(Standard links)
|
@jitendrapurohit style warning |
e34e501
to
08d32cb
Compare
i have built similar functionality using extension : https://github.com/Skvare/com.skvare.jobchecker |
@sunilpawar your extension looks nice & slightly more advanced than this. I think it's OK to have some functionality in core & an extension if people want more - I'm wondering what your thoughts are? |
@eileenmcnaughton |
@jitendrapurohit this sounds great! It would be a start in addressing the following two issues: |
CRM/Utils/Check/Component/Env.php
Outdated
return []; | ||
} | ||
|
||
$message = "<p>The following scheduled jobs failed on the last run:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you wrap the strings in ts()
? (this line, and other lines around it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late update @mlutfy. I've added the ts() now. Thanks.
@jitendrapurohit Unfortunately it's not quite right - please see: https://docs.civicrm.org/dev/en/latest/translation/#best-practices For example:
|
3622b89
to
4314c6f
Compare
Thanks @mlutfy I've updated the usage in the latest commit 👍 |
CRM/Utils/Check/Component/Env.php
Outdated
<td>' . ts('%1', [1 => $job['name']]) . ' </td> | ||
<td>' . ts('%1', [1 => $lastExecutionMessage]) . '</td> | ||
<td>' . ts('%1', [1 => $job['last_run']]) . '</td> | ||
<td>' . ts('<a href=\'%1\'>View Job Log</a>', [1 => $viewLogURL]) . '</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do instead:
<td><a href="' . $viewLogURL . '"> . ts('View Job Log') . '</a></td>
This way it avoids adding a new string to translate (and HTML should be avoided when possible).
$ grep -r 'View Job Log'
CRM/Admin/Page/Job.php: 'name' => ts('View Job Log'),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with the above suggestion 👍
CRM/Utils/Check/Component/Env.php
Outdated
if (!empty($lastExecutionMessage) && strpos($lastExecutionMessage, 'Failure') !== FALSE) { | ||
$viewLogURL = CRM_Utils_System::url('civicrm/admin/joblog', "jid={$job['id']}&reset=1"); | ||
$html .= '<tr> | ||
<td>' . ts('%1', [1 => $job['name']]) . ' </td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ts
is not necessary here. Job names are not translatable (they are set/translated during the installation, in civicrm_data.xx_XX.mysql
).
The other changes are good, so just these tiny 3 edits and we're done :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
CRM/Utils/Check/Component/Env.php
Outdated
$html .= '<tr> | ||
<td>' . ts('%1', [1 => $job['name']]) . ' </td> | ||
<td>' . ts('%1', [1 => $lastExecutionMessage]) . '</td> | ||
<td>' . ts('%1', [1 => $job['last_run']]) . '</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ts
not necessary for the above two lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed now. Thanks.
4314c6f
to
62f17a5
Compare
@jitendrapurohit Thank you! Merging based on code review, feedback from other reviewers, and also |
I remember seeing this PR and not really paying attention because I always dealt with this issue another way, but after rolling out 5.46 I see this is a good thing™. 🎉 |
Overview
Add alert to display scheduled job errors
Before
Schedule job fails silently. Civi core doesn't provide an inbuilt option to notify admins.
From https://chat.civicrm.org/civicrm/pl/8wbq1y3j4tdeumnf1iuie44a5o
After
Alert displayed on the system status page. Eg