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

ezplatform-solr-search-engine // float/double content creation issues with german locale

    XMLWordPrintable

Details

    Description

      Using a different locale (such as de_DE) will cause content publishing to fail, if this content includes a float value.

      steps to reproduce
      • setup an eZPublish 5.4.5 environment, with ezplatform-solr-search-engine bundled.
      • create a custom class (test_class), including a text field and a float field
      • setup a command as follows:
      class ExampleCommand extends \Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand {
      
        /**
         * Configures the command
         */
        protected function configure() {
          $this->setName('ezpublish:cookbook:example');
        }
      
        /**
         * Executes the command
         * @param InputInterface $input
         * @param OutputInterface $output
         */
        protected function execute(InputInterface $input, OutputInterface $output) {
          setlocale(LC_ALL, 'de_DE.UTF-8');
          
          $repository = $this->getContainer()->get('ezpublish.api.repository');
      
          $repository->setCurrentUser($repository->getUserService()->loadUser(14));
      
          $contentService = $repository->getContentService();
          $locationService = $repository->getLocationService();
          $contentTypeService = $repository->getContentTypeService();
      
          $contentType = $contentTypeService->loadContentTypeByIdentifier('test_class');
          $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB');
      
          $contentCreateStruct->setField('title', 'Test Content');
          $contentCreateStruct->setField('value', 5.4);
      
          $locationCreateStruct = $locationService->newLocationCreateStruct(2);
          $draft = $contentService->createContent($contentCreateStruct, array($locationCreateStruct));
          $content = $contentService->publishVersion($draft->versionInfo);
        }
      }
      
      • execute the command
      • Expected result => Content is published
      • Actual result => Operation fails with an exception.
       [RuntimeException]                                                                                                                                                                                                                          
        Wrong HTTP status received from Solr: 400array (                                                                                                                                                                                            
          0 =>                                                                                                                                                                                                                                      
          EzSystems\EzPlatformSolrSearchEngine\Gateway\Message::__set_state(array(                                                                                                                                                                  
             'headers' =>                                                                                                                                                                                                                           
            array (                                                                                                                                                                                                                                 
              'version' => '1.1',                                                                                                                                                                                                                   
              'status' => 400,                                                                                                                                                                                                                      
              'Content-Type' => 'text/plain;charset=UTF-8',                                                                                                                                                                                         
            ),                                                                                                                                                                                                                                      
             'body' => '{"responseHeader":{"status":400,"QTime":1},"error":{"msg":"ERROR: [doc=location76enggb] Error adding field \'cs_5228_value_value_f\'=\'5,4\' msg=For input string: \\"5,4\\"","code":400}}                                  
        ',                                                                                                                                                                                                                                          
          )),                                                                                                                                                                                                                                       
       

      In solr log, the following is echoed

      ERROR org.apache.solr.core.SolrCore  – org.apache.solr.common.SolrException: ERROR: [doc=location76enggb] Error adding field 'cs_5228_value_value_f'='5,4' msg=For input string: "5,4"
      
      note
      • if we comment the setLocale or setField('value' lines, the content is published without constraints

      Attachments

        Activity

          People

            Unassigned Unassigned
            joaquim.cavalleri-obsolete@ez.no Joaquim Cavalleri (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: