Fix: Clear hooks on plugin uninstall

Fixes error with gesior-shop-system clear-cache.php being called, despite it's removed
This commit is contained in:
slawkens
2026-04-11 17:49:22 +02:00
parent a27b8a4fa5
commit 4145d9eb3c
2 changed files with 25 additions and 0 deletions

View File

@@ -14,6 +14,26 @@ class Hooks
self::$_hooks[$hook->type()][] = $hook; self::$_hooks[$hook->type()][] = $hook;
} }
public function unregister($name, $type, $file): void
{
if (is_string($type)) {
$type = constant($type);
}
if(!isset(self::$_hooks[$type])) {
return;
}
foreach(self::$_hooks[$type] as $id => $hook) {
if($name == $hook->name()
&& $type == $hook->type()
&& $file == $hook->file()
) {
unset(self::$_hooks[$type][$id]);
}
}
}
public function trigger($type, $params = []): bool public function trigger($type, $params = []): bool
{ {
$ret = true; $ret = true;

View File

@@ -868,6 +868,11 @@ class Plugins {
} }
} }
global $hooks;
foreach($plugin_info['hooks'] ?? [] as $name => $info) {
$hooks->unregister($name, $info['type'], $info['file']);
}
clearCache(); clearCache();
return true; return true;
} }