diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php index e58930b26..ad3f2b873 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php @@ -61,8 +61,17 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $value; } + // Prevent a too lenient boolean conversion on non-postgresql platforms + if ($platform->getName() !== 'postgresql') { + if ($value !== 1 && $value !== 0 && $value !== '1' && $value !== '0' && !is_bool($value)) { + throw ConversionException::conversionFailed($value, $this->getName()); + } + } + try { - $showRaaContactInformationOption = new ShowRaaContactInformationOption($value); + $showRaaContactInformationOption = new ShowRaaContactInformationOption( + $platform->convertFromBoolean($value) + ); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain $doctrineExceptionMessage = ConversionException::conversionFailedFormat( diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php index 5d591365f..b26e7fd99 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php @@ -61,8 +61,15 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $value; } + // Prevent a too lenient boolean conversion on non-postgresql platforms + if ($platform->getName() !== 'postgresql') { + if ($value !== 1 && $value !== 0 && $value !== '1' && $value !== '0' && !is_bool($value)) { + throw ConversionException::conversionFailed($value, $this->getName()); + } + } + try { - $useRaLocationsOption = new UseRaLocationsOption($value); + $useRaLocationsOption = new UseRaLocationsOption($platform->convertFromBoolean($value)); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain $doctrineExceptionMessage = ConversionException::conversionFailedFormat(