Skip to content

Commit

Permalink
guess correct plugin_id, clear cache completely
Browse files Browse the repository at this point in the history
  • Loading branch information
tgloeggl committed Nov 11, 2024
1 parent 6178ec1 commit 22591b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions install/install.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Migrate from plugin version 2, if any
UPDATE plugins SET enabled = 'no' WHERE pluginclassname = 'OpenCast';
INSERT IGNORE INTO schema_version (domain, branch, version) SELECT 'OpencastV3' as domain, branch, version FROM schema_version WHERE domain = 'OpenCast';
UPDATE schema_version SET version = 0 WHERE domain = 'OpenCast';
REPLACE INTO schema_version (domain, branch, version) SELECT 'OpencastV3' as domain, branch, version FROM schema_version WHERE domain = 'OpenCast';

12 changes: 8 additions & 4 deletions migrations/096_fix_v3.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public function up()

// fix tool activations and plugin activations
$old_plugin_id = $db->query("SELECT pluginid FROM plugins WHERE pluginclassname = 'OpenCast'")->fetchColumn();
$new_plugin_id = $db->query("SELECT pluginid FROM plugins WHERE pluginclassname = 'OpencastV3'")->fetchColumn();

// guess new plugin id
$new_plugin_id = $db->query("SELECT MAX(pluginid) FROM plugins")->fetchColumn() + 1;

if (!empty($old_plugin_id) && !empty($new_plugin_id)) {
$stmt = $db->prepare("UPDATE tools_activated SET plugin_id = ':new' WHERE plugin_id = ':old'");
Expand All @@ -40,10 +42,12 @@ public function up()
]);
}

// clear cache for autoloader classes
// Clear the whole Stud.IP cache to make the plugin work correctlu
$cache = StudipCacheFactory::getCache();
$cache_key = 'STUDIP#autoloader-classes';
$cache->expire($cache_key);
$cache->flush();

// disable migrations for old plugin to prevent accidential deletion of oc-data
$db->exec("DELETE FROM schema_version WHERE domain = 'OpenCast'");
}

public function down()
Expand Down

0 comments on commit 22591b5

Please sign in to comment.