fix issue in route and widget unregister: we should remove only if both arguments are different. Also only register routes and widgets if they are not yet registered

This commit is contained in:
Mario
2026-03-25 10:16:49 +00:00
parent 1774140307
commit 1ec0e91405
2 changed files with 16 additions and 2 deletions

View File

@@ -8,6 +8,13 @@ class Route {
static function register($file,$modname) {
$rt = self::get();
foreach ($rt as $r) {
if ($r[0] === $file && $r[1] === $modname) {
return;
}
}
$rt[] = [ $file, $modname ];
self::set($rt);
}
@@ -17,7 +24,7 @@ class Route {
if($rt) {
$n = [];
foreach($rt as $r) {
if($r[0] !== $file && $r[1] !== $modname) {
if(!($r[0] === $file && $r[1] === $modname)) {
$n[] = $r;
}
}

View File

@@ -8,6 +8,13 @@ class Widget {
static function register($file,$widget) {
$rt = self::get();
foreach ($rt as $r) {
if ($r[0] === $file && $r[1] === $widget) {
return;
}
}
$rt[] = [ $file, $widget ];
self::set($rt);
}
@@ -17,7 +24,7 @@ class Widget {
if($rt) {
$n = [];
foreach($rt as $r) {
if($r[0] !== $file && $r[1] !== $widget) {
if(!($r[0] === $file && $r[1] === $widget)) {
$n[] = $r;
}
}