From 468c8d39c350e23b9bf17efc45e9a2ff66956699 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 9 May 2018 16:15:55 +0800 Subject: [PATCH] MDL-62351 privacy: check that subsystem/plugintype exist --- blog/classes/privacy/provider.php | 2 +- competency/classes/privacy/provider.php | 2 +- .../feedback/editpdf/classes/privacy/provider.php | 2 +- privacy/tests/provider_test.php | 12 ++++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/blog/classes/privacy/provider.php b/blog/classes/privacy/provider.php index 398d5a3f22c..7fb78533d55 100644 --- a/blog/classes/privacy/provider.php +++ b/blog/classes/privacy/provider.php @@ -72,7 +72,7 @@ class provider implements // coursemoduleid, courseid, moduleid, groupid, rating, usermodified. ], 'privacy:metadata:post'); - $collection->link_subsystem('core_comments', 'privacy:metadata:core_comments'); + $collection->link_subsystem('core_comment', 'privacy:metadata:core_comments'); $collection->link_subsystem('core_files', 'privacy:metadata:core_files'); $collection->link_subsystem('core_tag', 'privacy:metadata:core_tag'); diff --git a/competency/classes/privacy/provider.php b/competency/classes/privacy/provider.php index fc9964940ff..686d6a3a91b 100644 --- a/competency/classes/privacy/provider.php +++ b/competency/classes/privacy/provider.php @@ -211,7 +211,7 @@ class provider implements ], 'privacy:metadata:competency_userevidencecomp'); // Comments can be left on learning plans and competencies. - $collection->link_subsystem('core_comments', 'privacy:metadata:core_comments'); + $collection->link_subsystem('core_comment', 'privacy:metadata:core_comments'); return $collection; } diff --git a/mod/assign/feedback/editpdf/classes/privacy/provider.php b/mod/assign/feedback/editpdf/classes/privacy/provider.php index e61e7812101..71706046d67 100644 --- a/mod/assign/feedback/editpdf/classes/privacy/provider.php +++ b/mod/assign/feedback/editpdf/classes/privacy/provider.php @@ -59,7 +59,7 @@ class provider implements metadataprovider, assignfeedback_provider { ]; $collection->add_database_table('assignfeedback_editpdf_quick', $quickdata, 'privacy:metadata:tablepurpose'); $collection->add_subsystem_link('core_files', [], 'privacy:metadata:filepurpose'); - $collection->add_subsystem_link('core_fileconverted', [], 'privacy:metadata:conversionpurpose'); + $collection->add_subsystem_link('core_fileconverter', [], 'privacy:metadata:conversionpurpose'); return $collection; } diff --git a/privacy/tests/provider_test.php b/privacy/tests/provider_test.php index 3ca7e7e58e7..943d54e7643 100644 --- a/privacy/tests/provider_test.php +++ b/privacy/tests/provider_test.php @@ -128,6 +128,18 @@ class provider_testcase extends advanced_testcase { $this->assertTrue($DB->get_manager()->table_exists($item->get_name())); } + if ($item instanceof \core_privacy\local\metadata\types\plugintype_link) { + // Check that plugin type is valid. + $this->assertTrue(array_key_exists($item->get_name(), \core_component::get_plugin_types())); + } + + if ($item instanceof subsystem_link) { + // Check that core subsystem exists. + list($plugintype, $pluginname) = \core_component::normalize_component($item->get_name()); + $this->assertEquals('core', $plugintype); + $this->assertTrue(\core_component::is_core_subsystem($pluginname)); + } + if ($summary = $item->get_summary()) { // Summary is optional, but when provided must be a valid string identifier. $this->assertInternalType('string', $summary);