Details
-
Bug
-
Resolution: Fixed
-
Medium
-
2015.01, 2015.07
-
None
-
Operating System: CentOS 7.0 x64
PHP Version: 5.4.16
Database and version: Mariadb 5.5
Browser (and version): Firefox 35
Description
The REST API does not accept an Integer as the input for a Float field while an integer is a perfectly valid float number
This can be tested with PlatformUI or with the following cURL call:
curl 'http://ezpublish5.loc/api/ezp/v2/content/objects'\ -H 'X-CSRF-Token: GZ9piZqxv3QCNdfRC28ldKvTx-vD4QNsT5oMNdWuOC8'\ -H 'Content-Type: application/vnd.ez.api.ContentCreate+json'\ -H 'Accept: application/vnd.ez.api.Content+json' \ -H 'Cookie: PHPSESSID=mfrmhjg8ako10lmd1ihg8n6n61'\ --data-binary '{"ContentCreate":{"ContentType":{"_href":"/api/ezp/v2/content/types/57"},"mainLanguageCode":"eng-GB","LocationCreate":{"ParentLocation":{"_href":"/api/ezp/v2/content/locations/1/2"},"sortField":"PATH","sortOrder":"ASC"},"Section":null,"alwaysAvailable":"true","remoteId":null,"modificationDate":"2015-02-19T14:15:07.537Z","fields":{"field":[{"fieldDefinitionIdentifier":"name","fieldValue":"Test float"},{"fieldDefinitionIdentifier":"float","fieldValue":10}]}}}'
The result is a 406 error:
{ "ErrorMessage": { "_media-type": "application\/vnd.ez.api.ErrorMessage+json", "errorCode": 406, "errorMessage": "Not Acceptable", "errorDescription": "Argument '$value->value' is invalid: expected value to be of type 'float', got 'integer'", "trace": "#0 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/FieldType\/FieldType.php(400): eZ\\Publish\\Core\\FieldType\\Float\\Type->checkValueStructure(Object(eZ\\Publish\\Core\\FieldType\\Float\\Value))\n#1 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/Repository\/ContentService.php(600): eZ\\Publish\\Core\\FieldType\\FieldType->acceptValue(Object(eZ\\Publish\\Core\\FieldType\\Float\\Value))\n#2 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/SignalSlot\/ContentService.php(241): eZ\\Publish\\Core\\Repository\\ContentService->createContent(Object(eZ\\Publish\\Core\\Repository\\Values\\Content\\ContentCreateStruct), Array)\n#3 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Server\/Controller\/Content.php(257): eZ\\Publish\\Core\\SignalSlot\\ContentService->createContent(Object(eZ\\Publish\\Core\\Repository\\Values\\Content\\ContentCreateStruct), Array)\n#4 [internal function]: eZ\\Publish\\Core\\REST\\Server\\Controller\\Content->createContent()\n#5 \/home\/dp\/dev\/ezpublish-community\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php(145): call_user_func_array(Array, Array)\n#6 \/home\/dp\/dev\/ezpublish-community\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php(66): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#7 \/home\/dp\/dev\/ezpublish-community\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/DependencyInjection\/ContainerAwareHttpKernel.php(64): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#8 \/home\/dp\/dev\/ezpublish-community\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/Kernel.php(185): Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#9 \/home\/dp\/dev\/ezpublish-community\/web\/index.php(81): Symfony\\Component\\HttpKernel\\Kernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#10 {main}", "file": "\/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/FieldType\/Float\/Type.php", "line": 233 } }
Steps to Reproduce
– Crete a content type with a float attribute
– In platformUI, create an object of the previous Content Type and in the float field, use a number (10 for instance) instead of a float
– Publish the object
Attachments
Issue Links
- testing discovered
-
EZP-24826 Integer/Float fields do not raise an error/warning with big numbers (>2^64)
- Closed