From 36d842e0e78db70dd007eb87a74ba378954057f0 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 5 Sep 2023 13:41:54 +0100 Subject: [PATCH] MDL-79266 core: require plugins always define subplugin lang strings. --- lib/classes/plugin_manager.php | 18 ++---------------- lib/upgrade.txt | 2 ++ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 27df5b75e29..54b48905a7b 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -591,19 +591,12 @@ class core_plugin_manager { * @return string */ public function plugintype_name($type) { - if (get_string_manager()->string_exists('type_' . $type, 'core_plugin')) { // For most plugin types, their names are defined in core_plugin lang file. return get_string('type_' . $type, 'core_plugin'); - } else if ($parent = $this->get_parent_of_subplugin($type)) { // If this is a subplugin, try to ask the parent plugin for the name. - if (get_string_manager()->string_exists('subplugintype_' . $type, $parent)) { - return $this->plugin_name($parent) . ' / ' . get_string('subplugintype_' . $type, $parent); - } else { - return $this->plugin_name($parent) . ' / ' . $type; - } - + return $this->plugin_name($parent) . ' / ' . get_string('subplugintype_' . $type, $parent); } else { return $type; } @@ -620,19 +613,12 @@ class core_plugin_manager { * @return string */ public function plugintype_name_plural($type) { - if (get_string_manager()->string_exists('type_' . $type . '_plural', 'core_plugin')) { // For most plugin types, their names are defined in core_plugin lang file. return get_string('type_' . $type . '_plural', 'core_plugin'); - } else if ($parent = $this->get_parent_of_subplugin($type)) { // If this is a subplugin, try to ask the parent plugin for the name. - if (get_string_manager()->string_exists('subplugintype_' . $type . '_plural', $parent)) { - return $this->plugin_name($parent) . ' / ' . get_string('subplugintype_' . $type . '_plural', $parent); - } else { - return $this->plugin_name($parent) . ' / ' . $type; - } - + return $this->plugin_name($parent) . ' / ' . get_string('subplugintype_' . $type . '_plural', $parent); } else { return $type; } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 6f62d0ddae3..aae2ade36ac 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -10,6 +10,8 @@ information provided here is intended especially for developers. drag/drop, which can be used to add transition effects in calling code * course_modinfo now has a purge_course_modules_cache() method, which takes a list of cmids and purges them all in a single cache set. +* The `core_plugin_manager::plugintype_name[_plural]` methods now require language strings for subplugin types always + be defined in plugins (via `subplugintype_` and `subplugintype__plural` language strings) * Behat generators can now implement the function finish_generate_ to detect when the whole list of elements have been generated. * New return value 'icon' has been added to the 'external_files' webservice structure. This return value represents the relative path to the relevant file type icon based on the file's mime type. -- 2.43.0