Details
-
Bug
-
Resolution: Fixed
-
High
-
5.0, 5.1
-
None
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 );