Skip to content
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
wants to merge 11 commits into
base: 4.6
Choose a base branch
from

Conversation

barw4
Copy link
Contributor

@barw4 barw4 commented Jul 1, 2024

🎫 Issue IBX-8418

Related PRs:

ibexa/admin-ui#1321
https://github.com/ibexa/content-tree/pull/85

Description:

Currently, drafts without a location (so not yet published) that are orphaned due to missing ancestor location are forever stuck in the void. They cause multiple issues in different parts of DXP and they are not easily removable.

This PR makes sure that every time a location is trashed drafts under this given location or its child locations are removed.

Documentation:

Probably required

@barw4 barw4 added Bug Something isn't working Ready for review labels Jul 1, 2024
@barw4 barw4 self-assigned this Jul 1, 2024
@barw4 barw4 force-pushed the ibx-8418-deleting-orphaned-drafts branch from a70054e to 964cd70 Compare July 1, 2024 19:00
@barw4 barw4 force-pushed the ibx-8418-deleting-orphaned-drafts branch from 964cd70 to d737438 Compare July 2, 2024 09:54
Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I was thinking about something completely different during internal sync.

It's possible to create content items without Locations. Maybe in case of removal of a Location, just node assignment should be removed, keeping drafts "dangling"? These drafts should still be visible on Drafts view.

Just an idea. // POV ping @ibexa/php-dev

@alongosz alongosz requested a review from a team July 2, 2024 10:08
@barw4
Copy link
Contributor Author

barw4 commented Jul 2, 2024

@alongosz That's a cool idea, however, I think there are too many problems with drafts without node assignment. We cannot publish them using UI and I assume some other things will fail for them as well.

@barw4 barw4 force-pushed the ibx-8418-deleting-orphaned-drafts branch from f2e6dd0 to f80cb5c Compare July 7, 2024 12:52
@barw4 barw4 marked this pull request as ready for review July 8, 2024 08:57
@barw4 barw4 requested a review from alongosz July 8, 2024 08:57
@barw4 barw4 changed the title IBX-8418: Remove drafts when trashing its parent or ancestor location IBX-8418: Remove draft when trashing its parent or ancestor location Jul 8, 2024
{
$subLocations = $this->locationGateway->getChildren($locationId);
foreach ($subLocations as $subLocation) {
$this->deleteChildrenDrafts($subLocation['node_id']);
Copy link
Contributor

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?

Copy link
Contributor Author

@barw4 barw4 Aug 2, 2024

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.

@barw4 barw4 requested a review from Steveb-p August 2, 2024 12:58
@alongosz alongosz requested a review from a team August 5, 2024 12:31
@barw4 barw4 requested a review from alongosz August 6, 2024 12:37
@konradoboza konradoboza requested a review from a team August 7, 2024 05:54
@barw4 barw4 requested a review from konradoboza August 7, 2024 07:38
@barw4 barw4 requested a review from alongosz August 7, 2024 08:11
Copy link

sonarcloud bot commented Aug 7, 2024

@alongosz alongosz requested a review from a team August 7, 2024 10:16
@barw4 barw4 added Doc needed The changes require some documentation and removed Doc needed The changes require some documentation Investigation 🕵️ labels Aug 7, 2024
@barw4
Copy link
Contributor Author

barw4 commented Aug 7, 2024

@ibexa/design-team as we have this PR ready can we have some idea/design on how to inform a user in the Back Office that during content trashing we are deleting all not-yet published drafts? Perhaps an information in the modal (the one with active relations)?

@NataliaBecla
Copy link

@barw4 The only thing needed to be change is wording on notification. @juskora propose:
Dialog 1
Are you sure you want to send this content item to Trash ?
Sending this Content item to Trash will also send all drafts of this Location to Trash.

Dialog 2
Are you sure you want to send this Content item to Trash?
Sending ‘test_folder_19’ and its 1 Content item(s) to Trash will also send the sub-items and all drafts of this Location to Trash.

Screenshot 2024-08-07 at 15 45 03

@barw4
Copy link
Contributor Author

barw4 commented Aug 7, 2024

@NataliaBecla We have to change the wording.

Imo we have to specifically mention that only not-yet published drafts (so ones without location) will be removed and not only drafts of this Location - but also drafts of sub-locations. Besides, drafts are removed completely, not trashed.

Maybe something like:

Sending this Content item to Trash will also remove all drafts that have not been published yet and belong to the trashed subtree.

ping @ibexa/documentation

@juskora
Copy link
Contributor

juskora commented Aug 8, 2024

@NataliaBecla
After the discussion with @barw4 we decided to go this way:

Sending this content item to Trash will also delete all drafts of content items that haven’t beed published yet, and belong to the trashed subtree.

@barw4
Copy link
Contributor Author

barw4 commented Aug 8, 2024

@NataliaBecla @juskora information added in ibexa/admin-ui#1321 and https://github.com/ibexa/content-tree/pull/85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants