Skip to content

Commit

Permalink
MDL-62430 block_html: Check that block instances are block_html
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed May 14, 2018
1 parent 3960ad5 commit 641d878
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions blocks/html/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ public static function delete_data_for_all_users_in_context(\context $context) {
}

// 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));
if ($blockinstance = static::get_instance_from_context($context)) {
blocks_delete_instance($blockinstance);
}
}

/**
Expand All @@ -174,7 +176,9 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
if (!$context instanceof \context_block) {
continue;
}
blocks_delete_instance(static::get_instance_from_context($context));
if ($blockinstance = static::get_instance_from_context($context)) {
blocks_delete_instance($blockinstance);
}
}
}

Expand All @@ -187,6 +191,6 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
protected static function get_instance_from_context(\context_block $context) {
global $DB;

return $DB->get_record('block_instances', ['id' => $context->instanceid]);
return $DB->get_record('block_instances', ['id' => $context->instanceid, 'blockname' => 'html']);
}
}
2 changes: 1 addition & 1 deletion mod/lti/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static function delete_data_for_all_users_in_context(\context $context) {
}

if ($cm = get_coursemodule_from_id('lti', $context->instanceid)) {
$DB->delete_records('lti_submission', ['ltiid' => key($ltiidstocmids)]);
$DB->delete_records('lti_submission', ['ltiid' => $cm->instance]);
}
}

Expand Down

0 comments on commit 641d878

Please sign in to comment.