Skip to content

Commit

Permalink
MDL-79843 core: add support for plugin and plugintype deprecation
Browse files Browse the repository at this point in the history
This allows for plugins to be deprecated much in the same way as they
can be marked as deleted, via the plugin manager methods. Also supports
plugin types. Deprecated plugins are displayed as such during upgrade,
but will not block the upgrade process, nor will they interfere with
existing plugin statuses.
  • Loading branch information
snake committed Nov 13, 2023
1 parent 3d57a73 commit 2e23a1d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
24 changes: 19 additions & 5 deletions admin/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1062,8 +1062,15 @@ public function plugins_check_table(core_plugin_manager $pluginman, $version, ar

$header = new html_table_cell($pluginman->plugintype_name_plural($type));
$header->header = true;
$header->colspan = count($table->head);
$header = new html_table_row(array($header));
if ($pluginman::is_deprecated_plugin_type($type)) {
$header->colspan = count($table->head)-1; // Leave space in last column for type deprecated pill.
$statuspill = html_writer::span(get_string('plugintypedeprecated', 'core_plugin'),
'statustext badge badge-warning');
$header = new html_table_row(array($header, $statuspill));
} else {
$header->colspan = count($table->head);
$header = new html_table_row(array($header));
}
$header->attributes['class'] = 'plugintypeheader type-' . $type;

$numdisplayed[$type] = 0;
Expand Down Expand Up @@ -1145,6 +1152,12 @@ public function plugins_check_table(core_plugin_manager $pluginman, $version, ar
}
$status = html_writer::span(get_string('status_' . $statuscode, 'core_plugin'), $statusclass);

$deprecationstatus = '';
if ($pluginman::is_deprecated_standard_plugin($plugin->type, $plugin->name)) {
$deprecationstatus = html_writer::span(get_string('plugindeprecated', 'core_plugin'),
'statustext badge badge-warning');
}

if (!empty($installabortable[$plugin->component])) {
$status .= $this->output->single_button(
new moodle_url($this->page->url, array('abortinstall' => $plugin->component, 'confirmplugincheck' => 0)),
Expand All @@ -1170,7 +1183,7 @@ public function plugins_check_table(core_plugin_manager $pluginman, $version, ar
}
}

$status = new html_table_cell($sourcelabel.' '.$status);
$status = new html_table_cell($sourcelabel.' '.$status.' '.$deprecationstatus);
if ($plugin->pluginsupported != null) {
$requires = new html_table_cell($this->required_column($plugin, $pluginman, $version, $CFG->branch));
} else {
Expand All @@ -1188,8 +1201,9 @@ public function plugins_check_table(core_plugin_manager $pluginman, $version, ar

} else if ($statusisboring and $dependenciesok and empty($availableupdates)) {
// no change is going to happen to the plugin - display it only
// if the user wants to see the full list
if (empty($options['full'])) {
// if the user wants to see the full list, or it's a deprecated plugin.
if (empty($options['full']) && !$pluginman::is_deprecated_plugin_type($plugin->type) &&
!$pluginman::is_deprecated_standard_plugin($plugin->type, $plugin->name)) {
continue;
}

Expand Down
2 changes: 2 additions & 0 deletions lang/en/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
$string['plugincheckattention'] = 'Plugins requiring attention';
$string['pluginchecknone'] = 'No plugins require your attention now';
$string['pluginchecknotice'] = 'This page displays plugins that may require your attention during the upgrade, such as new plugins to be installed, plugins to be upgraded, missing plugins etc. Additional plugins are displayed if there is an available update for them. It is recommended that you check whether there are more recent versions of plugins available and update their source code before continuing with this Moodle upgrade.';
$string['plugindeprecated'] = 'Deprecated';
$string['plugintypedeprecated'] = 'Deprecated plugin type';
$string['plugindisable'] = 'Disable';
$string['plugindisabled'] = 'Disabled';
$string['pluginenable'] = 'Enable';
Expand Down
43 changes: 43 additions & 0 deletions lib/classes/plugin_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,47 @@ public static function is_deleted_standard_plugin($type, $name) {
return in_array($name, $plugins[$type]);
}

/**
* Defines a list of all plugins that were originally shipped in the standard Moodle distribution,
* but have been deprecated, or of plugins which are of a deprecated type.
*
* The main purpose of this list is to highlight deprecated plugins during upgrade.
*
* Final deprecation of a core plugin should result in removal of the plugin, at which point the plugin should be listed in the
* is_deleted_standard_plugin() method.
*
* @param string $type plugin type
* @param string $name plugin name
* @return bool true if deprecated, false otherwise.
*/
public static function is_deprecated_standard_plugin($type, $name) {
if (self::is_deprecated_plugin_type($type)) {
return true;
}
$plugins = [
'ltisource' => []
];
if (!isset($plugins[$type])) {
return false;
}
return in_array($name, $plugins[$type]);
}

/**
* A list of all plugin types which have been deprecated.
*
* The main purpose of this list is to highlight deprecated plugin types during upgrade.
*
* @param string $type the string type, e.g. 'ltisource'
* @return bool true if deprecated, false otherwise.
*/
public static function is_deprecated_plugin_type($type) {
$plugins = [
'ltisource'
];
return in_array($type, $plugins);
}

/**
* Defines a white list of all plugins shipped in the standard Moodle distribution
*
Expand Down Expand Up @@ -1922,6 +1963,8 @@ public static function standard_plugins_list($type) {
'gradebookservices', 'memberships', 'profile', 'toolproxy', 'toolsettings', 'basicoutcomes'
),

"ltisource" => [],

"ltixsource" => [],

'mlbackend' => array(
Expand Down

0 comments on commit 2e23a1d

Please sign in to comment.