Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-24038

Float field does not accept an integer as input

    XMLWordPrintable

Details

    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

        Activity

          People

            Unassigned Unassigned
            paulo.nunes-obsolete@ez.no Paulo Nunes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 50 minutes
                50m