MDL-62430 block_html: Check that block instances are block_html
authorDavid Monllao <davidm@moodle.com>
Mon, 14 May 2018 13:52:31 +0000 (15:52 +0200)
committerDavid Monllao <davidm@moodle.com>
Mon, 14 May 2018 15:06:57 +0000 (17:06 +0200)
blocks/html/classes/privacy/provider.php
mod/lti/classes/privacy/provider.php

index f3659f7..21131fe 100644 (file)
@@ -159,7 +159,9 @@ class provider implements
         }
 
         // 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);
+        }
     }
 
     /**
@@ -174,7 +176,9 @@ class provider implements
             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);
+            }
         }
     }
 
@@ -187,6 +191,6 @@ class provider implements
     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']);
     }
 }
index d308eca..220caa5 100644 (file)
@@ -164,7 +164,7 @@ class provider implements
         }
 
         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]);
         }
     }