Журнал: смена состава прав/событий (список) теперь попадает в «что изменилось», раскрытие не двигает столбцы таблицы
This commit is contained in:
1 parent
7174b0d01d
commit
64521aaf87
3 files changed
+74
-4
No files matched your search
@@ -86,7 +86,7 @@ final class Audit
|
||||
foreach ($after as $field => $value) {
|
||||
$old = $before[$field] ?? null;
|
||||
|
||||
if ((string) $old === (string) $value) {
|
||||
if (self::same($old, $value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,26 @@ final class Audit
|
||||
return $changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Списки (права роли, события вебхука) сравниваем по составу, а не как
|
||||
* строку: PHP приводит любой массив к «Array», и смена состава читалась
|
||||
* бы как «ничего не изменилось».
|
||||
*/
|
||||
private static function same(mixed $old, mixed $value): bool
|
||||
{
|
||||
if (is_array($old) || is_array($value)) {
|
||||
$old = array_map('strval', (array) $old);
|
||||
$value = array_map('strval', (array) $value);
|
||||
|
||||
sort($old);
|
||||
sort($value);
|
||||
|
||||
return $old === $value;
|
||||
}
|
||||
|
||||
return (string) $old === (string) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, array{0: mixed, 1: mixed}> $changes
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user