mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-23 02:29:34 +00:00
ParameterDTO: Don't overwrite $unit if it's not empty
This commit is contained in:
parent
c9e391bca6
commit
1d520d9318
1 changed files with 2 additions and 5 deletions
|
|
@ -72,9 +72,8 @@ class ParameterDTO
|
|||
//Try to extract number and unit from value (allow leading +)
|
||||
if (empty($unit)) {
|
||||
[$number, $unit] = self::splitIntoValueAndUnit(ltrim($parts[0], " +")) ?? [$parts[0], null];
|
||||
$unit2 = null;
|
||||
} else {
|
||||
$unit2 = $unit;
|
||||
$number = $parts[0];
|
||||
}
|
||||
// If the second part has some extra info, we'll save that into value_text
|
||||
if (!empty($unit) && preg_match('/^(.+' . preg_quote($unit) . ')\s*(.+)$/', $parts[1], $matches) > 0) {
|
||||
|
|
@ -83,9 +82,7 @@ class ParameterDTO
|
|||
} else {
|
||||
$value_text2 = null;
|
||||
}
|
||||
if (empty($unit2)) {
|
||||
[$number2, $unit2] = self::splitIntoValueAndUnit(ltrim($parts[1], " +")) ?? [$parts[1], null];
|
||||
}
|
||||
[$number2, $unit2] = self::splitIntoValueAndUnit(ltrim($parts[1], " +")) ?? [$parts[1], $unit];
|
||||
|
||||
//If both parts have the same unit and both values are numerical, we assume it is a range
|
||||
if ($unit === $unit2 && is_numeric($number) && is_numeric($number2)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue