diff --git a/blocks/html/classes/privacy/provider.php b/blocks/html/classes/privacy/provider.php
index 93c9f6ab983..1f6405e3f31 100644
--- a/blocks/html/classes/privacy/provider.php
+++ b/blocks/html/classes/privacy/provider.php
@@ -153,6 +153,11 @@ class provider implements
* @param context $context The specific context to delete data for.
*/
public static function delete_data_for_all_users_in_context(\context $context) {
+
+ if (!$context instanceof \context_block) {
+ return;
+ }
+
// The only way to delete data for the html block is to delete the block instance itself.
blocks_delete_instance(static::get_instance_from_context($context));
}
@@ -165,6 +170,10 @@ class provider implements
public static function delete_data_for_user(approved_contextlist $contextlist) {
// The only way to delete data for the html block is to delete the block instance itself.
foreach ($contextlist as $context) {
+
+ if (!$context instanceof \context_block) {
+ continue;
+ }
blocks_delete_instance(static::get_instance_from_context($context));
}
}
diff --git a/mod/choice/classes/privacy/provider.php b/mod/choice/classes/privacy/provider.php
index cfb7ee1b882..ee0c0a49258 100644
--- a/mod/choice/classes/privacy/provider.php
+++ b/mod/choice/classes/privacy/provider.php
@@ -184,6 +184,11 @@ class provider implements
if (empty($context)) {
return;
}
+
+ if (!$context instanceof \context_module) {
+ return;
+ }
+
$instanceid = $DB->get_field('course_modules', 'instance', ['id' => $context->instanceid], MUST_EXIST);
$DB->delete_records('choice_answers', ['choiceid' => $instanceid]);
}
@@ -202,6 +207,10 @@ class provider implements
$userid = $contextlist->get_user()->id;
foreach ($contextlist->get_contexts() as $context) {
+
+ if (!$context instanceof \context_module) {
+ return;
+ }
$instanceid = $DB->get_field('course_modules', 'instance', ['id' => $context->instanceid], MUST_EXIST);
$DB->delete_records('choice_answers', ['choiceid' => $instanceid, 'userid' => $userid]);
}