#106304Extbase IntegerConverter fails validation on float input resulting in wrong values
Description
In a domain model, I have an attribute “size” where the user should enter its body-size in cm, e.g. 179.
The model attribute is defined as protected int $size = 0;
If the user enters “1,79”, the \TYPO3\CMS\Extbase\Property\TypeConverter\IntegerConverter throws the error “1,79” is no integer, which is right (Btw: this message is not translatable)
But if the user enters “ 1.79 “, the value passes the check and is saved as value “1” in the database!
The reason is, that “1.79” as float value passes the is_numeric($source) check (failure 1) and even worse, its casted to int in return (int)$source resulting in the wrong value (failure 2).
I can’t see an easy fix here, because is_integer() can’t be used (it failed in multiple other places).
*Current workaround:*
In my case I can just replace the dot “.” for the “size” argument and write it back to the request in inside the controller’s initializeAction():
public function initializeExampleAction(): void
{
$arguments = $this->request->getArguments();
$arguments['user']['size'] = str_replace('.', '', $arguments['user']['size'] ?? '');
$this->request = $this->request->withArguments($arguments);
}Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.