From 889f35fc2649b8a2f068affacc339a5200b967e4 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 20 Jan 2023 16:30:15 +0000 Subject: [PATCH] MDL-69838 core: final removal of deprecated 310 methods. --- .../output/mustache_helper_collection.php | 15 ++------ lib/form/classes/filetypes_util.php | 36 ++++--------------- lib/form/tests/filetypes_util_test.php | 22 ------------ .../mustache_helper_collection_test.php | 12 ------- lib/upgrade.txt | 4 +++ 5 files changed, 13 insertions(+), 76 deletions(-) diff --git a/lib/classes/output/mustache_helper_collection.php b/lib/classes/output/mustache_helper_collection.php index 0c72ff60b62..e2f7b332eb9 100644 --- a/lib/classes/output/mustache_helper_collection.php +++ b/lib/classes/output/mustache_helper_collection.php @@ -175,18 +175,9 @@ class mustache_helper_collection extends \Mustache_HelperCollection { } /** - * Parse the given string and remove any reference to disallowed helpers. - * - * @deprecated Deprecated since Moodle 3.10 (MDL-69050) - use {@see self::strip_disallowed_helpers()} - * @param string[] $disallowedlist List of helper names to strip - * @param string $string String to parse - * @return string Parsed string + * @deprecated Deprecated since Moodle 3.10 (MDL-69050) - use {@see strip_disallowed_helpers} */ - public function strip_blacklisted_helpers($disallowedlist, $string) { - - debugging('mustache_helper_collection::strip_blacklisted_helpers() is deprecated. ' . - 'Please use mustache_helper_collection::strip_disallowed_helpers() instead.', DEBUG_DEVELOPER); - - return $this->strip_disallowed_helpers($disallowedlist, $string); + public function strip_blacklisted_helpers() { + throw new \coding_exception('\core\output\mustache_helper_collection::strip_blacklisted_helpers() has been removed.'); } } diff --git a/lib/form/classes/filetypes_util.php b/lib/form/classes/filetypes_util.php index f11791bd1b7..6021ce54061 100644 --- a/lib/form/classes/filetypes_util.php +++ b/lib/form/classes/filetypes_util.php @@ -430,23 +430,10 @@ class filetypes_util { } /** - * Should the given file type be considered as a part of the given list. - * - * If multiple types are provided, all of them must be part of the - * list. Empty type is part of any list. Any type is part of an - * empty list. - * - * @deprecated since Moodle 3.10 MDL-69050 - please use {@see self::is_listed()} instead. - * @param string|array $types File type or list of types to be checked. - * @param string|array $list An array or string listing the types to check against. - * @return boolean + * @deprecated since Moodle 3.10 MDL-69050 - please use {@see is_listed} instead. */ - public function is_whitelisted($types, $list) { - - debugging('filetypes_util::is_whitelisted() is deprecated. Please use filetypes_util::is_listed() instead.', - DEBUG_DEVELOPER); - - return $this->is_listed($types, $list); + public function is_whitelisted() { + throw new \coding_exception('\core_form\filetypes_util::is_whitelisted() has been removed.'); } /** @@ -476,21 +463,10 @@ class filetypes_util { } /** - * Returns all types that are not part of the given list. - * - * This is similar check to the {@see self::is_listed()} but this one actually returns the extra types. - * - * @deprecated since Moodle 3.10 MDL-69050 - please use {@see self::get_not_whitelisted()} instead. - * @param string|array $types File type or list of types to be checked. - * @param string|array $list An array or string listing the types to check against. - * @return array Types not present in the list. + * @deprecated since Moodle 3.10 MDL-69050 - please use {@see get_not_listed} instead. */ - public function get_not_whitelisted($types, $list) { - - debugging('filetypes_util::get_not_whitelisted() is deprecated. Please use filetypes_util::get_not_listed() instead.', - DEBUG_DEVELOPER); - - return $this->get_not_listed($types, $list); + public function get_not_whitelisted() { + throw new \coding_exception('\core_form\filetypes_util::get_not_whitelisted() has been removed.'); } /** diff --git a/lib/form/tests/filetypes_util_test.php b/lib/form/tests/filetypes_util_test.php index 26dcc80193d..5bf2d73a45d 100644 --- a/lib/form/tests/filetypes_util_test.php +++ b/lib/form/tests/filetypes_util_test.php @@ -484,26 +484,4 @@ class filetypes_util_test extends advanced_testcase { $util = new filetypes_util(); $this->assertSame($expected, $util->get_unknown_file_types($filetypes)); } - - /** - * Test that a debugging noticed is displayed when calling is_whitelisted(). - */ - public function test_deprecation_is_whitelisted() { - - $util = new filetypes_util(); - $this->assertTrue($util->is_whitelisted('txt', 'text/plain')); - $this->assertDebuggingCalled('filetypes_util::is_whitelisted() is deprecated. ' . - 'Please use filetypes_util::is_listed() instead.', DEBUG_DEVELOPER); - } - - /** - * Test that a debugging noticed is displayed when calling get_not_whitelisted(). - */ - public function test_deprecation_get_not_whitelisted() { - - $util = new filetypes_util(); - $this->assertEmpty($util->get_not_whitelisted('txt', 'text/plain')); - $this->assertDebuggingCalled('filetypes_util::get_not_whitelisted() is deprecated. ' . - 'Please use filetypes_util::get_not_listed() instead.', DEBUG_DEVELOPER); - } } diff --git a/lib/tests/output/mustache_helper_collection_test.php b/lib/tests/output/mustache_helper_collection_test.php index c8b6773e2db..43b6b89fb4b 100644 --- a/lib/tests/output/mustache_helper_collection_test.php +++ b/lib/tests/output/mustache_helper_collection_test.php @@ -171,16 +171,4 @@ class mustache_helper_collection_test extends \advanced_testcase { $this->assertTrue($goodcalled); $this->assertFalse($badcalled); } - - /** - * Test that calling deprecated method strip_blacklisted_helpers() still works and shows developer debugging. - */ - public function test_deprecated_strip_blacklisted_helpers() { - - $collection = new mustache_helper_collection(null, ['js']); - $stripped = $collection->strip_blacklisted_helpers(['js'], '{{#js}} JS {{/js}}'); - $this->assertEquals('{{}}', $stripped); - $this->assertDebuggingCalled('mustache_helper_collection::strip_blacklisted_helpers() is deprecated. ' . - 'Please use mustache_helper_collection::strip_disallowed_helpers() instead.', DEBUG_DEVELOPER); - } } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index f20bbf09ba2..e454f4875f5 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -56,6 +56,10 @@ information provided here is intended especially for developers. The old class locations have been aliased for backwards compatibility and will emit a deprecation notice in a future release. +* The following methods, deprecated since 3.10, have been removed and can no longer be used: + - `\core\output\mustache_helper_collection::strip_blacklisted_helpers` + - `\core_form\filetypes_util::is_whitelisted` + - `\core_form\filetypes_util::get_not_whitelisted` * Convert a floating value to an integer in lib/graphlib.php to avoid PHP 8.1 deprecated function error. * The $required parameter for \core_external\external_description is now being validated in order to prevent unintentionally passing incorrect parameters to the external_description's (and its subclasses') constructors (e.g. the parameter