Truncate integer values before inserting them
- Address https://github.com/friendica/friendica/issues/12486#issuecomment-1383250353
This commit is contained in:
parent
594f738c6d
commit
3b99b98678
1 changed files with 4 additions and 0 deletions
|
@ -87,6 +87,10 @@ class DbaDefinition
|
||||||
$data[$field] = mb_substr($data[$field], 0, $result[1]);
|
$data[$field] = mb_substr($data[$field], 0, $result[1]);
|
||||||
} elseif (is_string($data[$field]) && preg_match("/binary\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) {
|
} elseif (is_string($data[$field]) && preg_match("/binary\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) {
|
||||||
$data[$field] = substr($data[$field], 0, $result[1]);
|
$data[$field] = substr($data[$field], 0, $result[1]);
|
||||||
|
} elseif (is_numeric($data[$field]) && $definition[$table]['fields'][$field]['type'] === 'int') {
|
||||||
|
$data[$field] = min(max((int)$data[$field], -2147483648), 2147483647);
|
||||||
|
} elseif (is_numeric($data[$field]) && $definition[$table]['fields'][$field]['type'] === 'int unsigned') {
|
||||||
|
$data[$field] = min(max((int)$data[$field], 0), 4294967295);
|
||||||
}
|
}
|
||||||
$fields[$field] = $data[$field];
|
$fields[$field] = $data[$field];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue