Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
e7bfc2e8
Commit
e7bfc2e8
authored
10 months ago
by
Jan-Hendrik Willms
Committed by
David Siegfried
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fixes #3977
Closes #3977 Merge request
studip/studip!2945
parent
8474ee10
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
db/migrations/5.1.57_cleanup_tool_activations.php
+23
-0
23 additions, 0 deletions
db/migrations/5.1.57_cleanup_tool_activations.php
lib/plugins/engine/PluginManager.class.php
+34
-26
34 additions, 26 deletions
lib/plugins/engine/PluginManager.class.php
with
57 additions
and
26 deletions
db/migrations/5.1.57_cleanup_tool_activations.php
0 → 100644
+
23
−
0
View file @
e7bfc2e8
<?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
]);
}
};
This diff is collapsed.
Click to expand it.
lib/plugins/engine/PluginManager.class.php
+
34
−
26
View file @
e7bfc2e8
...
...
@@ -427,41 +427,49 @@ class PluginManager
$this
->
plugins
[
$id
][
'name'
]
=
$name
;
$this
->
plugins
[
$id
][
'path'
]
=
$path
;
$this
->
plugins
[
$id
][
'type'
]
=
$type
;
}
else
{
foreach
(
$this
->
plugins
as
$plugin
)
{
$common_types
=
array_intersect
(
$type
,
$plugin
[
'type'
]);
return
$id
;
}
foreach
(
$this
->
plugins
as
$plugin
)
{
$common_types
=
array_intersect
(
$type
,
$plugin
[
'type'
]);
if
(
count
(
$common_types
)
>
0
&&
$plugin
[
'position'
]
>=
$position
)
{
$position
=
$plugin
[
'position'
]
+
1
;
if
(
count
(
$common_types
)
>
0
&&
$plugin
[
'position'
]
>=
$position
)
{
$position
=
$plugin
[
'position'
]
+
1
;
}
}
}
$sql
=
'INSERT INTO plugins (
$sql
=
'INSERT INTO plugins (
pluginname, pluginclassname, pluginpath,
plugintype, navigationpos, dependentonid
) VALUES (?,?,?,?,?,?)'
;
$stmt
=
$db
->
prepare
(
$sql
);
$stmt
->
execute
([
$name
,
$class
,
$path
,
join
(
','
,
$type
),
$position
,
$depends
]);
$id
=
$db
->
lastInsertId
();
$this
->
plugins
[
$id
]
=
[
'id'
=>
$id
,
'name'
=>
$name
,
'class'
=>
$class
,
'path'
=>
$path
,
'type'
=>
$type
,
'enabled'
=>
false
,
'position'
=>
$position
,
'depends'
=>
$depends
];
$stmt
=
$db
->
prepare
(
$sql
);
$stmt
->
execute
([
$name
,
$class
,
$path
,
join
(
','
,
$type
),
$position
,
$depends
]);
$id
=
$db
->
lastInsertId
();
$this
->
readPluginInfos
();
$this
->
plugins
[
$id
]
=
[
'id'
=>
$id
,
'name'
=>
$name
,
'class'
=>
$class
,
'path'
=>
$path
,
'type'
=>
$type
,
'enabled'
=>
false
,
'position'
=>
$position
,
'depends'
=>
$depends
];
$this
->
readPluginInfos
();
$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'"
);
}
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
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment