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

FIX Remove implicitly added item #423

Conversation

sabina-talipova
Copy link
Contributor

@sabina-talipova sabina-talipova commented Oct 24, 2023

Description

  • Implicitly added item to the ChangeSet will be removed together with parent explicitly added item if ChangeSet has State = 'open'.
  • Implicitly added item to the ChangeSet cannot be remove if explicitly added parent item was removed and ChangeSet has State = 'published'.
    We should remove implicitly added item together with parent item even if ChangeSet was already published.

Parent issue

@sabina-talipova sabina-talipova marked this pull request as ready for review October 25, 2023 01:10
@sabina-talipova sabina-talipova force-pushed the pulls/1.13/remove-implicitly-added-item branch from d0c0890 to 528ebe5 Compare October 25, 2023 01:22
Copy link
Contributor

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

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

That's an elegant solution. I'm just thinking we should add a few extra scenarios in the test coverage.

tests/php/ChangeSetTest.php Show resolved Hide resolved
tests/php/ChangeSetTest.php Show resolved Hide resolved
@sabina-talipova sabina-talipova force-pushed the pulls/1.13/remove-implicitly-added-item branch 4 times, most recently from 2ae54c9 to c2a4961 Compare October 27, 2023 03:08
src/ChangeSet.php Outdated Show resolved Hide resolved
@sabina-talipova sabina-talipova force-pushed the pulls/1.13/remove-implicitly-added-item branch from c2a4961 to fa265ef Compare October 27, 2023 03:57
Copy link
Contributor

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

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

Consider adding an optional $message parameter to the assertChangeSetLooksLike helper method. That could help make the test more readable.

You could provide assumption like:

  • Removing an explicitly defined ChangeSetItem removes all its implicit ChangeSetItems.
  • Removing an explicitly defined ChangeSetItem does not remove its implicit ChangeSetItem if that item is also referenced by another a third one.
  • Removing an explicitly defined ChangeSetItem does not remove its implicit ChangeSetItem if that item is also explicitly added to the changeset

This is more in the nice to have category.

$changeset->addObject($mid1);
$changeset->addObject($mid2);
$changeset->addObject($mid3);
$changeset->addObject($end1); // Item end1 explisitly added to ChangeSet
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$changeset->addObject($end1); // Item end1 explisitly added to ChangeSet
$changeset->addObject($end1); // Item end1 explicitly added to ChangeSet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

tests/php/ChangeSetTest.php Show resolved Hide resolved
@sabina-talipova sabina-talipova force-pushed the pulls/1.13/remove-implicitly-added-item branch from fa265ef to 53c86be Compare October 30, 2023 20:12
@sabina-talipova sabina-talipova force-pushed the pulls/1.13/remove-implicitly-added-item branch from 53c86be to d614204 Compare October 30, 2023 20:25
Copy link
Contributor

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

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

LGTM

@maxime-rainville maxime-rainville merged commit 59299b6 into silverstripe:1.13 Nov 1, 2023
9 checks passed
@maxime-rainville maxime-rainville deleted the pulls/1.13/remove-implicitly-added-item branch November 1, 2023 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants