mirror of
https://github.com/opnsense/core.git
synced 2026-10-12 02:20:36 +00:00
Revert "mvc: UidField: allow reuse of UID 0 for system scope users"
This reverts commit649bcb2186. There is a bug in the old and new behaviour, but without a proper test case this will not fix easily. stable/26.7 doesn't use this yet so it's sane to hotfix. PR: https://github.com/opnsense/core/issues/10992 (cherry picked from commit7bbd7a3c4a)
This commit is contained in:
@@ -52,24 +52,18 @@ class UidField extends IntegerField
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$in_scope = false;
|
||||
$uids = [];
|
||||
|
||||
if ($this->fieldLoaded) {
|
||||
if (empty((string)$this) && $this->fieldLoaded) {
|
||||
$uids = [];
|
||||
foreach ($this->getParentModel()->user->iterateItems() as $user) {
|
||||
$uids[] = $user->uid->asInt();
|
||||
}
|
||||
$in_scope = !$this->getParentNode()->scope->isEqual('system');
|
||||
}
|
||||
|
||||
if (!$this->isSet() || !$in_scope) {
|
||||
for ($i = 2000; $in_scope; $i++) {
|
||||
for ($i = 2000; true; $i++) {
|
||||
if (!in_array($i, $uids)) {
|
||||
parent::setValue((string)$i);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} elseif (empty((string)$this)) {
|
||||
parent::setValue($value);
|
||||
}
|
||||
}
|
||||
@@ -93,6 +87,7 @@ class UidField extends IntegerField
|
||||
$this->setValue(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* retrieve field validators for this field type
|
||||
* @return array returns Text/regex validator
|
||||
|
||||
Reference in New Issue
Block a user