-
Notifications
You must be signed in to change notification settings - Fork 13
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
IBX-8418: Remove draft when trashing its parent or ancestor location #398
Open
barw4
wants to merge
11
commits into
4.6
Choose a base branch
from
ibx-8418-deleting-orphaned-drafts
base: 4.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7773657
IBX-8418: Remove drafts when trashing its parent or ancestor location
barw4 7473d19
IBX-8418: Implement unit tests
barw4 f80cb5c
IBX-8418: Fix unit test
barw4 8bc808c
IBX-8418: Provided integration test
barw4 61d439e
IBX-8418: Updated baseline
barw4 8450bf5
IBX-8418: Applied review remarks
barw4 5050f67
IBX-8418: CS
barw4 a96b80a
IBX-8418: Fixed integration test
barw4 06a156e
IBX-8418: Fixed integration test
barw4 52ef245
IBX-8418: CS
barw4 1e54ec0
IBX-8418: Fixup
barw4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
tests/integration/Core/Repository/TrashService/TrashTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\Core\Repository\TrashService; | ||
|
||
use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; | ||
use Ibexa\Tests\Integration\Core\RepositoryTestCase; | ||
use PHPUnit\Framework\Assert; | ||
|
||
/** | ||
* @covers \Ibexa\Contracts\Core\Repository\TrashService | ||
*/ | ||
final class TrashTest extends RepositoryTestCase | ||
{ | ||
/** | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception | ||
*/ | ||
public function testTrashLocationDeletesChildrenDrafts(): void | ||
{ | ||
$trashService = self::getTrashService(); | ||
$contentService = self::getContentService(); | ||
|
||
$folder = $this->createFolder(['eng-GB' => 'Folder'], 2); | ||
$folderMainLocationId = $folder->getVersionInfo()->getContentInfo()->getMainLocationId(); | ||
Assert::assertIsNumeric($folderMainLocationId); | ||
|
||
$childFolder = $this->createFolder( | ||
['eng-GB' => 'Child folder'], | ||
$folderMainLocationId, | ||
); | ||
$childFolderMainLocationId = $childFolder->getVersionInfo()->getContentInfo()->getMainLocationId(); | ||
Assert::assertIsNumeric($childFolderMainLocationId); | ||
|
||
$secondDepthChildFolder = $this->createFolder( | ||
['eng-GB' => 'Second depth folder'], | ||
$childFolderMainLocationId, | ||
); | ||
$secondDepthChildFolderLocationId = $secondDepthChildFolder | ||
->getVersionInfo() | ||
->getContentInfo() | ||
->getMainLocationId() | ||
; | ||
Assert::assertIsNumeric($secondDepthChildFolderLocationId); | ||
|
||
$draft1 = $this->createFolderDraft(['eng-GB' => 'Folder draft 1'], $folderMainLocationId); | ||
$draft2 = $this->createFolderDraft(['eng-GB' => 'Folder draft 2'], $childFolderMainLocationId); | ||
$draft3 = $this->createFolderDraft(['eng-GB' => 'Folder draft 3'], $childFolderMainLocationId); | ||
$draftSecondDepth = $this->createFolderDraft( | ||
['eng-GB' => 'Folder draft 4'], | ||
$secondDepthChildFolderLocationId, | ||
); | ||
|
||
$locationToTrash = $this->getLocationService()->loadLocation($folderMainLocationId); | ||
barw4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
$trashService->trash($locationToTrash); | ||
|
||
$draftIds = [ | ||
$draft1->getId(), | ||
$draft2->getId(), | ||
$draft3->getId(), | ||
$draftSecondDepth->getId(), | ||
]; | ||
|
||
foreach ($draftIds as $draftId) { | ||
try { | ||
$contentService->loadContentInfo($draftId); | ||
$this->fail( | ||
sprintf('Expected NotFoundException not thrown for draft ID = %d', $draftId), | ||
); | ||
} catch (NotFoundException $e) { | ||
self::assertInstanceOf(NotFoundException::class, $e); | ||
} | ||
} | ||
konradoboza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A recursive call? Won't this be a massive performance penalty for deep trees?
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.
Few lines above we have the same situation and it was there for ages 🤷🏻 : https://github.com/ibexa/core/blob/main/src/lib/Persistence/Legacy/Content/TreeHandler.php#L196
Removing it in a single query may not be easy as this table is tree-like with the only information being of a record's parent.