Skip to content

Commit 5e22366

Browse files
committed
dont remove subplugins in upgrade job
1 parent e70ee5a commit 5e22366

File tree

18 files changed

+103
-60
lines changed

18 files changed

+103
-60
lines changed

db/upgrade.php

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2323
*/
2424

25-
use tool_lifecycle\local\manager\workflow_manager;
26-
2725
/**
2826
* Fix any gaps in the workflows sortindex.
2927
*/
@@ -500,7 +498,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) {
500498

501499
}
502500

503-
if ($oldversion < 2025041200) {
501+
if ($oldversion < 2025041400) {
504502

505503
// Changing precision of field instancename on table tool_lifecycle_trigger to (100).
506504
$table = new xmldb_table('tool_lifecycle_trigger');
@@ -562,40 +560,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) {
562560
$dbman->add_field($table, $field);
563561
}
564562

565-
// Remove sitecourse subplugin if there is one, otherwise set all workflows to includesitecourse = 1.
566-
$purgecaches = false;
567-
$pluginmanager = core_plugin_manager::instance();
568-
if ($plugininfo = $pluginmanager->get_plugin_info('lifecycletrigger_sitecourse')) {
569-
$trace = new \null_progress_trace();
570-
$plugininfo->uninstall($trace);
571-
if ($pluginmanager->is_plugin_folder_removable($plugininfo->component)) {
572-
$pluginmanager->uninstall_plugin($plugininfo->component, $trace);
573-
$pluginmanager->remove_plugin_folder($plugininfo);
574-
}
575-
$purgecaches = true;
576-
} else {
577-
$DB->set_field('tool_lifecycle_workflow', 'includesitecourse', 1);
578-
}
579-
580-
// Remove delayedcourses subplugin if there is one, otherwise set all workflows to includedelayedcourses = 1.
581-
$pluginmanager = core_plugin_manager::instance();
582-
if ($plugininfo = $pluginmanager->get_plugin_info('lifecycletrigger_delayedcourses')) {
583-
$trace = new \null_progress_trace();
584-
$plugininfo->uninstall($trace);
585-
if ($pluginmanager->is_plugin_folder_removable($plugininfo->component)) {
586-
$pluginmanager->uninstall_plugin($plugininfo->component, $trace);
587-
$pluginmanager->remove_plugin_folder($plugininfo);
588-
}
589-
$purgecaches = true;
590-
} else {
591-
$DB->set_field('tool_lifecycle_workflow', 'includedelayedcourses', 1);
592-
}
593-
594-
if ($purgecaches) {
595-
purge_all_caches();
596-
}
597-
598-
upgrade_plugin_savepoint(true, 2025041200, 'tool', 'lifecycle');
563+
upgrade_plugin_savepoint(true, 2025041400, 'tool', 'lifecycle');
599564

600565
}
601566

remove.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Remove trigger subplugins sitecourse and delayedcourses.
19+
*
20+
* @package tool_lifecycle
21+
* @copyright 2025 Thomas Niedermaier University Münster
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
25+
require_once(__DIR__ . '/../../../config.php');
26+
27+
$PAGE->set_context(context_system::instance());
28+
29+
require_login(null, false);
30+
require_capability('moodle/site:config', context_system::instance());
31+
32+
echo "<div>Start ".userdate(time())."</div>";
33+
34+
// Remove sitecourse subplugin if there is one, otherwise set all workflows to includesitecourse = 1.
35+
$purgecaches = false;
36+
$pluginmanager = core_plugin_manager::instance();
37+
if ($plugininfo = $pluginmanager->get_plugin_info('lifecycletrigger_sitecourse')) {
38+
echo "<div>Sitecourse Start ".userdate(time())."</div>";
39+
$trace = new \null_progress_trace();
40+
$plugininfo->uninstall($trace);
41+
echo "<div>Sitecourse After Plugin uninstall ".userdate(time())."</div>";
42+
if ($pluginmanager->is_plugin_folder_removable($plugininfo->component)) {
43+
$pluginmanager->uninstall_plugin($plugininfo->component, $trace);
44+
$pluginmanager->remove_plugin_folder($plugininfo);
45+
echo "<div>Sitecourse Removed ".userdate(time())."</div>";
46+
}
47+
$purgecaches = true;
48+
echo "<div>Sitecourse End ".userdate(time())."</div>";
49+
} else {
50+
echo "<div>Sitecourse No Plugin Found ".userdate(time())."</div>";
51+
$DB->set_field('tool_lifecycle_workflow', 'includesitecourse', 1);
52+
}
53+
54+
// Remove delayedcourses subplugin if there is one, otherwise set all workflows to includedelayedcourses = 1.
55+
$pluginmanager = core_plugin_manager::instance();
56+
if ($plugininfo = $pluginmanager->get_plugin_info('lifecycletrigger_delayedcourses')) {
57+
echo "<div>Delayedcourses Start ".userdate(time())."</div>";
58+
$trace = new \null_progress_trace();
59+
$plugininfo->uninstall($trace);
60+
echo "<div>Delayedcourses After Plugin Uninstall ".userdate(time())."</div>";
61+
if ($pluginmanager->is_plugin_folder_removable($plugininfo->component)) {
62+
$pluginmanager->uninstall_plugin($plugininfo->component, $trace);
63+
$pluginmanager->remove_plugin_folder($plugininfo);
64+
echo "<div>Delayedcourses Removed ".userdate(time())."</div>";
65+
}
66+
$purgecaches = true;
67+
echo "<div>Delayedcourses End ".userdate(time())."</div>";
68+
} else {
69+
echo "<div>Delayedcourses No Plugin Found ".userdate(time())."</div>";
70+
$DB->set_field('tool_lifecycle_workflow', 'includedelayedcourses', 1);
71+
}
72+
73+
if ($purgecaches) {
74+
echo "<div>Purge Caches ".userdate(time())."</div>";
75+
purge_all_caches();
76+
}
77+
78+
echo "<div>End ".userdate(time())."</div>";

step/adminapprove/db/upgrade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function xmldb_lifecyclestep_adminapprove_upgrade($oldversion) {
3737

3838
global $DB;
3939
$dbman = $DB->get_manager();
40-
if ($oldversion < 2025041200) {
40+
if ($oldversion < 2025041400) {
4141

4242
// Define table lifecyclestep_adminapprove to be created.
4343
$table = new xmldb_table('lifecyclestep_adminapprove');
@@ -57,7 +57,7 @@ function xmldb_lifecyclestep_adminapprove_upgrade($oldversion) {
5757
}
5858

5959
// Adminapprove savepoint reached.
60-
upgrade_plugin_savepoint(true, 2025041200, 'lifecyclestep', 'adminapprove');
60+
upgrade_plugin_savepoint(true, 2025041400, 'lifecyclestep', 'adminapprove');
6161
}
6262
return true;
6363
}

step/adminapprove/version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025041200;
27+
$plugin->version = 2025041400;
2828
$plugin->component = 'lifecyclestep_adminapprove';
2929
$plugin->dependencies = [
30-
'tool_lifecycle' => 2025041200,
30+
'tool_lifecycle' => 2025041400,
3131
];
3232
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
3333
$plugin->release = 'v4.5-r1';

step/createbackup/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025041200;
27+
$plugin->version = 2025041400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecyclestep_createbackup';
3030
$plugin->release = 'v4.5-r1';

step/deletecourse/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025041200;
27+
$plugin->version = 2025041400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecyclestep_deletecourse';
3030
$plugin->release = 'v4.5-r1';

step/duplicate/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025041200;
27+
$plugin->version = 2025041400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecyclestep_duplicate';
3030
$plugin->release = 'v4.5-r1';

step/email/db/upgrade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function xmldb_lifecyclestep_email_upgrade($oldversion) {
3737

3838
global $DB;
3939
$dbman = $DB->get_manager();
40-
if ($oldversion < 2025041200) {
40+
if ($oldversion < 2025041400) {
4141
$table = new xmldb_table('lifecyclestep_email_notified');
4242

4343
// Adding fields to table lifecyclestep_email_notified.
@@ -57,7 +57,7 @@ function xmldb_lifecyclestep_email_upgrade($oldversion) {
5757
}
5858

5959
// Lifecycle savepoint reached.
60-
upgrade_plugin_savepoint(true, 2025041200, 'lifecyclestep', 'email');
60+
upgrade_plugin_savepoint(true, 2025041400, 'lifecyclestep', 'email');
6161
}
6262
return true;
6363
}

step/email/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
defined('MOODLE_INTERNAL') || die;
2626

2727

28-
$plugin->version = 2025041200;
28+
$plugin->version = 2025041400;
2929
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
3030
$plugin->component = 'lifecyclestep_email';
3131
$plugin->release = 'v4.5-r1';

step/makeinvisible/version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025041200;
27+
$plugin->version = 2025041400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecyclestep_makeinvisible';
3030
$plugin->dependencies = [
31-
'tool_lifecycle' => 2025041200,
31+
'tool_lifecycle' => 2025041400,
3232
];
3333
$plugin->release = 'v4.5-r1';
3434
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)