Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-39087 Use progress_trace class to display uninstallation progress

This is much better API than using the array passed by reference. At the
moment, it is pretty hacky as it abuses text_progress_trace to output
raw HTML echoed by uninstall_plugin() but that will be improved later
while moving the logic out of that function into the plugin_manager.
  • Loading branch information...
commit 3ca1b54642568a42c663f77af8940a59ae5c1229 1 parent c2d2001
@mudrd8mz mudrd8mz authored
Showing with 18 additions and 21 deletions.
  1. +5 −4 admin/plugins.php
  2. +6 −10 admin/renderer.php
  3. +7 −7 lib/pluginlib.php
View
9 admin/plugins.php
@@ -78,16 +78,17 @@
exit();
} else {
- $messages = array(); // Collect uninstall process messages here.
- $pluginman->uninstall_plugin($pluginfo->component, $messages);
+ $progress = new progress_trace_buffer(new text_progress_trace(), false);
+ $pluginman->uninstall_plugin($pluginfo->component, $progress);
+ $progress->finished();
if ($pluginman->is_plugin_folder_removable($pluginfo->component)) {
$continueurl = new moodle_url($PAGE->url, array('delete' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1));
- echo $output->plugin_uninstall_results_removable_page($pluginman, $pluginfo, $messages, $continueurl);
+ echo $output->plugin_uninstall_results_removable_page($pluginman, $pluginfo, $progress, $continueurl);
exit();
} else {
- echo $output->plugin_uninstall_results_page($pluginman, $pluginfo, $messages);
+ echo $output->plugin_uninstall_results_page($pluginman, $pluginfo, $progress);
exit();
}
}
View
16 admin/renderer.php
@@ -398,12 +398,12 @@ public function plugin_uninstall_confirm_page(plugin_manager $pluginman, plugini
*
* @param plugin_manager $pluginman
* @param plugin_info $pluginfo
- * @param array $messages list of strings, the log of the process
+ * @param progress_trace_buffer $progress
* @param moodle_url $continueurl URL to continue to remove the plugin folder
* @return string
*/
public function plugin_uninstall_results_removable_page(plugin_manager $pluginman, plugininfo_base $pluginfo,
- array $messages = array(), moodle_url $continueurl) {
+ progress_trace_buffer $progress, moodle_url $continueurl) {
$output = '';
$pluginname = $pluginman->plugin_name($pluginfo->component);
@@ -411,9 +411,7 @@ public function plugin_uninstall_results_removable_page(plugin_manager $pluginma
$output .= $this->output->header();
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
- foreach ($messages as $message) {
- $output .= $this->output->box($message, 'generalbox uninstallresultmessage');
- }
+ $output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
$confirm = $this->output->container(get_string('uninstalldeleteconfirm', 'core_plugin',
array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'uninstalldeleteconfirm');
@@ -434,10 +432,10 @@ public function plugin_uninstall_results_removable_page(plugin_manager $pluginma
*
* @param plugin_manager $pluginman
* @param plugin_info $pluginfo
- * @param array $messages list of strings, the log of the process
+ * @param progress_trace_buffer $progress
* @return string
*/
- public function plugin_uninstall_results_page(plugin_manager $pluginman, plugininfo_base $pluginfo, array $messages = array()) {
+ public function plugin_uninstall_results_page(plugin_manager $pluginman, plugininfo_base $pluginfo, progress_trace_buffer $progress) {
$output = '';
$pluginname = $pluginman->plugin_name($pluginfo->component);
@@ -445,9 +443,7 @@ public function plugin_uninstall_results_page(plugin_manager $pluginman, plugini
$output .= $this->output->header();
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
- foreach ($messages as $message) {
- $output .= $this->output->box($message, 'generalbox uninstallresultmessage');
- }
+ $output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
$output .= $this->output->box(get_string('uninstalldelete', 'core_plugin',
array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'generalbox uninstalldelete');
View
14 lib/pluginlib.php
@@ -531,10 +531,10 @@ public function can_uninstall_plugin($component) {
* mimic this future behaviour by wrapping that function call.
*
* @param string $component
- * @param array $messages log of the process is returned via this array
+ * @param progress_trace $progress traces the process
* @return bool true on success, false on errors/problems
*/
- public function uninstall_plugin($component, array &$messages) {
+ public function uninstall_plugin($component, progress_trace $progress) {
$pluginfo = $this->get_plugin_info($component);
@@ -542,8 +542,8 @@ public function uninstall_plugin($component, array &$messages) {
return false;
}
- // Give the pluginfo class a perform some steps.
- $result = $pluginfo->uninstall($messages);
+ // Give the pluginfo class a chance to execute some steps.
+ $result = $pluginfo->uninstall($progress);
if (!$result) {
return false;
}
@@ -551,7 +551,7 @@ public function uninstall_plugin($component, array &$messages) {
// Call the legacy core function to uninstall the plugin.
ob_start();
uninstall_plugin($pluginfo->type, $pluginfo->name);
- $messages[] = ob_get_clean();
+ $progress->output(ob_get_clean());
return true;
}
@@ -2859,10 +2859,10 @@ public function get_dir() {
* it is basically usable only for those plugin types that use the default
* uninstall tool provided by {@link self::get_default_uninstall_url()}.
*
- * @param array $messages list of uninstall log messages
+ * @param progress_trace $progress traces the process
* @return bool true on success, false on failure
*/
- public function uninstall(array &$messages) {
+ public function uninstall(progress_trace $progress) {
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.