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

contentService: Unable to delete a content with an empty file attribute

    XMLWordPrintable

Details

    Description

      Using the public API method $contentService->deleteContent(), we are unable to delete a content with an empty file attribute.

      The following exception is thrown:

      [ezcQueryInvalidParameterException]                                                     
      Argument '2' of method 'in' expects a non-empty array but an empty array was provided. 
      

      The error comes from the countFileReferences() method in
      eZ/Publish/Core/FieldType/BinaryBase/BinaryBaseStorage/Gateway/LegacyStorage.php which is called with a empty array as parameter.

      Steps to reproduce:

      1) Modify the 'File' class making the file 'File' attribute not required
      2) Create and delete a file content without file attribute value using the following command :

      $repository = $this->getContainer()->get( 'ezpublish.api.repository' );
      $userService = $repository->getUserService();
      $contentService = $repository->getContentService();
      $locationService = $repository->getLocationService();
      $contentTypeService = $repository->getContentTypeService();
      
      $output->writeln( "Logging in user..." );
      $repository->setCurrentUser( 
      	$userService->loadUserByCredentials( 'admin', 'admin' )
      );        
      
      $output->writeln( "Creating content struct..." );
      $contentCreateStruct = $contentService->newContentCreateStruct( 
      	$contentTypeService->loadContentTypeByIdentifier( 'file' ), 'eng-GB' 
      );
      $contentCreateStruct->setField( 'name', 'testfile' );
      
      $output->writeln( "Creating draft..." );
      $locationCreateStruct = $locationService->newLocationCreateStruct( 2 );
      $draft = $contentService->createContent( $contentCreateStruct, array( $locationCreateStruct ) );
      
      $output->writeln( "Publishing content version..." );
      $output->writeln( print_r( $draft->versionInfo , true ) );
      $content = $contentService->publishVersion( $draft->versionInfo );
      
      $output->writeln( "Deleting content..." );
      $contentService->deleteContent( $content->contentInfo );
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            joao.inacio-obsolete@ez.no Joao Inacio (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 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 - 4 hours, 36 minutes
                4h 36m