-
Notifications
You must be signed in to change notification settings - Fork 19
IBX-12460: Fixed external storage data not being deleted for legacy field type identifiers #827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 5.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,12 +7,14 @@ | |||||||||||||
|
|
||||||||||||||
| namespace Ibexa\Tests\Integration\Core\Repository\FieldType; | ||||||||||||||
|
|
||||||||||||||
| use Doctrine\DBAL\ParameterType; | ||||||||||||||
| use Ibexa\Contracts\Core\Repository; | ||||||||||||||
| use Ibexa\Contracts\Core\Repository\Exceptions\ContentTypeFieldDefinitionValidationException; | ||||||||||||||
| use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; | ||||||||||||||
| use Ibexa\Contracts\Core\Repository\Values\Content\Content; | ||||||||||||||
| use Ibexa\Contracts\Core\Repository\Values\Content\Field; | ||||||||||||||
| use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition; | ||||||||||||||
| use Ibexa\Core\Persistence\Legacy\Content\Gateway; | ||||||||||||||
| use Ibexa\Tests\Integration\Core\Repository\BaseTestCase; | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
|
|
@@ -953,6 +955,29 @@ public function testUpdateContentFails($failingValue, $expectedException) | |||||||||||||
| $this->updateContent($failingValue); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| protected function downgradeFieldTypeIdentifierToLegacyAlias( | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: either add to PHPDoc block that this touches |
||||||||||||||
| string $legacyAlias, | ||||||||||||||
| int $contentId, | ||||||||||||||
| int $versionNo, | ||||||||||||||
| int $fieldDefinitionId | ||||||||||||||
| ): void { | ||||||||||||||
| $connection = $this->getRawDatabaseConnection(); | ||||||||||||||
|
|
||||||||||||||
| $query = $connection->createQueryBuilder(); | ||||||||||||||
| $query | ||||||||||||||
| ->update(Gateway::CONTENT_FIELD_TABLE) | ||||||||||||||
| ->set('data_type_string', ':data_type_string') | ||||||||||||||
| ->setParameter('data_type_string', $legacyAlias, ParameterType::STRING) | ||||||||||||||
| ->andWhere('content_type_field_definition_id = :content_type_field_definition_id') | ||||||||||||||
| ->andWhere('version = :version') | ||||||||||||||
| ->andWhere('contentobject_id = :contentobject_id') | ||||||||||||||
| ->setParameter('content_type_field_definition_id', $fieldDefinitionId, ParameterType::INTEGER) | ||||||||||||||
| ->setParameter('version', $versionNo, ParameterType::INTEGER) | ||||||||||||||
| ->setParameter('contentobject_id', $contentId, ParameterType::INTEGER); | ||||||||||||||
|
|
||||||||||||||
| $query->executeStatement(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| protected function removeFieldDefinition() | ||||||||||||||
| { | ||||||||||||||
| $repository = $this->getRepository(); | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -842,6 +842,44 @@ public function testDeleteImageWithCorruptedName(): void | |
| // Expect no League\Flysystem\CorruptedPathDetected thrown | ||
| } | ||
|
|
||
| public function testDeleteContentRemovesImageStoredUnderLegacyFieldTypeIdentifier(): void | ||
| { | ||
| $ioService = $this->getSetupFactory()->getServiceContainer()->get(LegacyIOService::class); | ||
| $repository = $this->getRepository(); | ||
| $contentService = $repository->getContentService(); | ||
|
|
||
| self::assertInstanceOf(IOServiceInterface::class, $ioService); | ||
|
|
||
| $content = $this->publishNewImage( | ||
| __METHOD__, | ||
| new ImageValue( | ||
| [ | ||
| 'inputUri' => __DIR__ . '/_fixtures/image.jpg', | ||
| 'fileName' => 'image.jpg', | ||
| 'fileSize' => filesize(__DIR__ . '/_fixtures/image.jpg'), | ||
| 'alternativeText' => 'Alternative', | ||
| ] | ||
| ), | ||
| [2] | ||
| ); | ||
|
|
||
| $imageFieldDefinition = $content->getContentType()->getFieldDefinition('image'); | ||
| self::assertNotNull($imageFieldDefinition); | ||
|
|
||
| $this->assertImageExists(true, $ioService, $content); | ||
|
Comment on lines
+847
to
+869
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is not true for this portion. It's a duplicate of |
||
|
|
||
| $this->downgradeFieldTypeIdentifierToLegacyAlias( | ||
| 'ezimage', | ||
| $content->id, | ||
| $content->getVersionInfo()->versionNo, | ||
| $imageFieldDefinition->id | ||
| ); | ||
|
|
||
| $contentService->deleteContent($content->getVersionInfo()->getContentInfo()); | ||
|
|
||
| $this->assertImageExists(false, $ioService, $content); | ||
| } | ||
|
|
||
| /** | ||
| * @return array<string,mixed> | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire PHPDoc block can be actually dropped while at it, it doesn't provide any extra value due to strict typing.