Skip to content
Snippets Groups Projects
5.1.57_cleanup_tool_activations.php 637 B
Newer Older
Jan-Hendrik Willms's avatar
Jan-Hendrik Willms committed
<?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]);
    }
};