From 2bd5e80b10ffcb035063e0b2a6e9b08b4d9efd4f Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 13 Mar 2018 00:16:08 +0400 Subject: Rewritten 'local_webhooks_get_record' feature Signed-off-by: Valentin Popov --- lib.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib.php b/lib.php index fe6bc7f..4b8b53d 100644 --- a/lib.php +++ b/lib.php @@ -83,13 +83,10 @@ function local_webhooks_search_services_by_event($eventname, $active = false) { function local_webhooks_get_record($serviceid) { global $DB; - $servicerecord = $DB->get_record(LOCAL_WEBHOOKS_TABLE_SERVICES, array("id" => $serviceid), "*", MUST_EXIST); + $record = $DB->get_record(LOCAL_WEBHOOKS_TABLE_SERVICES, array("id" => $serviceid), "*", IGNORE_MISSING); + $record->events = local_webhooks_get_list_events_for_service($serviceid); - if (!empty($servicerecord->events)) { - $servicerecord->events = local_webhooks_deserialization_data($servicerecord->events); - } - - return $servicerecord; + return $record; } /** -- cgit v1.2.3