diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationField.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationField.php index 43cf1e7..9888e1c 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationField.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationField.php @@ -27,7 +27,8 @@ { throw new MissingRpcArgumentException('field'); } - $fieldName = InformationFieldName::tryFrom(strtoupper($rpcRequest->getParameter('field'))); + + $fieldName = InformationFieldName::tryFrom(strtoupper((string)$rpcRequest->getParameter('field'))); if($fieldName === null) { throw new InvalidRpcArgumentException('field'); @@ -38,11 +39,7 @@ { throw new MissingRpcArgumentException('value'); } - $value = $rpcRequest->getParameter('value'); - if(!$fieldName->validate($value)) - { - throw new InvalidRpcArgumentException('value'); - } + $value = (string)$rpcRequest->getParameter('value'); try { diff --git a/src/Socialbox/Managers/PeerInformationManager.php b/src/Socialbox/Managers/PeerInformationManager.php index ff3c149..a1952fc 100644 --- a/src/Socialbox/Managers/PeerInformationManager.php +++ b/src/Socialbox/Managers/PeerInformationManager.php @@ -31,6 +31,15 @@ { $peerUuid = $peerUuid->getUuid(); } + elseif(!Validator::validateUuid($peerUuid)) + { + throw new InvalidArgumentException('The given internal peer UUID is not a valid UUID V4'); + } + + if(!$property->validate($value)) + { + throw new InvalidArgumentException(sprintf('The given value %s is not valid for property %s', $value, $property->value)); + } if($privacyState === null) { @@ -79,10 +88,19 @@ { $peerUuid = $peerUuid->getUuid(); } + elseif(!Validator::validateUuid($peerUuid)) + { + throw new InvalidArgumentException('The given internal peer UUID is not a valid UUID V4'); + } if(!self::fieldExists($peerUuid, $property)) { - throw new DatabaseOperationException(sprintf('Cannot to update property %s for peer %s, property does not exist', $property->value, $peerUuid)); + self::addField($peerUuid, $property, $value); + } + + if(!$property->validate($value)) + { + throw new InvalidArgumentException(sprintf('The given value %s is not valid for property %s', $value, $property->value)); } try