diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d533645..cf0fd49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,3 +14,4 @@ jobs: disable_grunt: true disable_phplint: true disable_phpdoc: true + ignore_paths: errors diff --git a/classes/check/failingtaskcheck.php b/classes/check/failingtaskcheck.php index b62c270..ab37862 100644 --- a/classes/check/failingtaskcheck.php +++ b/classes/check/failingtaskcheck.php @@ -44,13 +44,18 @@ class failingtaskcheck extends check { * Constructor */ public function __construct($task = null) { - $this->id = 'cronfailingtasks'; - $this->name = get_string('checkfailingtaskcheck', 'tool_heartbeat'); $this->task = $task; - $this->actionlink = new \action_link( - new \moodle_url('/admin/tasklogs.php'), - get_string('tasklogs', 'tool_task')); + } + + /** + * A link to check task logs + * + * @return \action_link|null + */ + public function get_action_link(): ?\action_link { + $url = new \moodle_url('/admin/tasklogs.php'); + return new \action_link($url, get_string('tasklogs', 'tool_task')); } /** diff --git a/classes/hook_callbacks.php b/classes/hook_callbacks.php new file mode 100644 index 0000000..5d71fd4 --- /dev/null +++ b/classes/hook_callbacks.php @@ -0,0 +1,39 @@ +. + +namespace tool_heartbeat; + +/** + * Hook callbacks for tool_heartbeat. + * + * @package tool_heartbeat + * @author Benjamin Walker (benjaminwalker@catalyst-au.net) + * @copyright 2024 Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class hook_callbacks { + + /** + * Runs before HTTP headers. Used to ping the cachecheck. + * + * @param \core\hook\output\before_http_headers $hook + */ + public static function before_http_headers(\core\hook\output\before_http_headers $hook): void { + if (class_exists('\core\check\manager')) { + \tool_heartbeat\check\cachecheck::ping('web'); + } + } +} diff --git a/db/hooks.php b/db/hooks.php new file mode 100644 index 0000000..fac84b9 --- /dev/null +++ b/db/hooks.php @@ -0,0 +1,34 @@ +. + +/** + * Hook callbacks for tool_heartbeat + * + * @package tool_heartbeat + * @author Benjamin Walker (benjaminwalker@catalyst-au.net) + * @copyright 2024 Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$callbacks = [ + [ + 'hook' => \core\hook\output\before_http_headers::class, + 'callback' => '\tool_heartbeat\hook_callbacks::before_http_headers', + 'priority' => 0, + ], +]; diff --git a/lib.php b/lib.php index 9061ead..7114c3c 100644 --- a/lib.php +++ b/lib.php @@ -23,6 +23,9 @@ /** * Runs before HTTP headers. Used to ping the cachecheck. + * + * This is a legacy callback that is used for compatibility with older Moodle versions. + * Moodle 4.4+ will use tool_heartbeat\hook_callbacks::before_http_headers instead. */ function tool_heartbeat_before_http_headers() { if (class_exists('\core\check\manager')) { diff --git a/version.php b/version.php index 4edaf89..186f22f 100644 --- a/version.php +++ b/version.php @@ -24,9 +24,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024031400; -$plugin->release = 2024031400; // Match release exactly to version. +$plugin->version = 2024052000; +$plugin->release = 2024052000; // Match release exactly to version. $plugin->requires = 2020061500; // Support for 3.9 and above, due to the Check API. -$plugin->supported = [39, 401]; +$plugin->supported = [39, 404]; $plugin->component = 'tool_heartbeat'; $plugin->maturity = MATURITY_STABLE;