Skip to content
Snippets Groups Projects
Commit e7bfc2e8 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

fixes #3977

Closes #3977

Merge request studip/studip!2945
parent 8474ee10
No related branches found
No related tags found
No related merge requests found
<?php
/**
* @see https://gitlab.studip.de/studip/studip/-/issues/3977
*/
return new class extends Migration
{
public function description()
{
return 'Removes invalid tool activations (that are no longer connected '
. 'to a StandardPlugin';
}
protected function up()
{
$query = "DELETE FROM `tools_activated`
WHERE `plugin_id` NOT IN (
SELECT `pluginid`
FROM `plugins`
WHERE FIND_IN_SET(?, `plugintype`)
)";
DBManager::get()->execute($query, [StandardPlugin::class]);
}
};
...@@ -427,10 +427,7 @@ class PluginManager ...@@ -427,10 +427,7 @@ class PluginManager
$this->plugins[$id]['name'] = $name; $this->plugins[$id]['name'] = $name;
$this->plugins[$id]['path'] = $path; $this->plugins[$id]['path'] = $path;
$this->plugins[$id]['type'] = $type; $this->plugins[$id]['type'] = $type;
} else {
return $id;
}
foreach ($this->plugins as $plugin) { foreach ($this->plugins as $plugin) {
$common_types = array_intersect($type, $plugin['type']); $common_types = array_intersect($type, $plugin['type']);
...@@ -462,6 +459,17 @@ class PluginManager ...@@ -462,6 +459,17 @@ class PluginManager
$db->exec("INSERT INTO roles_plugins (roleid, pluginid) $db->exec("INSERT INTO roles_plugins (roleid, pluginid)
SELECT roleid, $id FROM roles WHERE `system` = 'y' AND rolename != 'Nobody'"); SELECT roleid, $id FROM roles WHERE `system` = 'y' AND rolename != 'Nobody'");
}
if (!in_array(StandardPlugin::class, $type)) {
ToolActivation::findEachBySQL(
function (ToolActivation $activation) use ($id) {
$this->setPluginActivated($id, $activation->range_id, false);
},
'plugin_id = ?',
[$id]
);
}
return $id; return $id;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment