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

BUGFIX: Re-introduce stricter checks for subtree en/disabling and tagging #5357

Merged

Conversation

bwaidelich
Copy link
Member

@bwaidelich bwaidelich commented Nov 9, 2024

Previously, when trying to disable an already disabled node, we just ignored that fact and did not produce any events. That leads to a potentially opaque behavior:

User A: log into backend
User B: log into backend
User A: Hide Node X
User B: Hide Node X
User B: Publish
User A: Rebase
User B: Unhide Node X
User B: Publish
User A: Rebase <--- now Node X is re-enabled even though User A had explicitly disabled it

With this change, the sequence is:

User A: log into backend
User B: log into backend
User A: Hide Node X
User B: Hide Node X
User B: Publish
User A: Rebase <--- this leads to a conflict because both users disabled the same node. And User A can now explicitly decide to ignore that fact

Basically reverts #4284 again because we have conflict resolution

…ging

Previously, when trying to disable an already disabled node, we just ignored that fact and did not produce any events.
That leads to a potentially opaque behavior:

```
User A: log into backend
User B: log into backend
User A: Hide Node X
User B: Hide Node X
User B: Publish
User A: Rebase
User B: Unhide Node X
User B: Publish
User A: Rebase <--- now Node X is re-enabled even though User A had explicitly disabled it
```

With this change, the sequence is:

```
User A: log into backend
User B: log into backend
User A: Hide Node X
User B: Hide Node X
User B: Publish
User A: Rebase <--- this leads to a conflict because both users disabled the same node. And User A can now explicitly decide to ignore that fact
```

Note: This mostly reverts #4284 that was introduced because we did not have a conflict resolution in place

Related: #4284
@bwaidelich
Copy link
Member Author

Current, intransparent behavior:

5357_screenrecording_bug.mov

And with the fix applied:

5357_screenrecording_fix.mov

@mhsdesign
Copy link
Member

Thanks, does that mean that EventsToPublish is never empty and we can remove all this ->isEmpty check logic?

@bwaidelich
Copy link
Member Author

Thanks, does that mean that EventsToPublish is never empty and we can remove all this ->isEmpty check logic?

Right, that's why I removed it :)

Copy link
Member

@mhsdesign mhsdesign left a comment

Choose a reason for hiding this comment

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

sorry i must have been blind :D Thanks a lot, reduced complexity imo and is more correct.

Currently the Ui conflict resolution could be improved though but it handles it:

image

@mhsdesign mhsdesign merged commit 9ba879a into 9.0 Nov 12, 2024
11 checks passed
@bwaidelich bwaidelich deleted the bugfix/4284-reintroduce-stricter-checks-for-subtree-tagging branch November 12, 2024 09:44
@mhsdesign
Copy link
Member

i thought already if there are other places publishing 0 events, and yes there are: SetNodeProperties with 0 properties :D

Now this introduces a regression and throws in the event publishing

Writable events must contain at least one event

Options to fix this:
A: Reintroduce the write publish events empty check ... meh ...
B: Throw an exception in SetNodeProperties ... not simple to use without any properties?
C: Catch this case in the command handler earlier and return fast
D: Nullable events to publish?

@bwaidelich
Copy link
Member Author

meh..

E: Prevent PropertiesToWrite to exist empty

@mhsdesign
Copy link
Member

E would mean that the initialProperties of a node creation must never be empty and thus the field has to be nullable then.

@bwaidelich
Copy link
Member Author

the field has to be nullable then

Right, but i think that would be fine in this case. It is already nullable in CreateNodeAggregateWithNode::create() and would make this case more explicit IMO.
OTOH it would mean that NodeAggregateWithNodeWasCreated::fromArray() would have to filter an empty $values['initialPropertyValues']

@kitsunet
Copy link
Member

Sounds fine to me, I am considering in my head if we would ever need to make a difference between no initial properties and empty initial properties, but I don't quite see it yet. (I could construct a case were you want to avoid defaultValues and eg. we make it so that empty initial fills the defaults while null initial will not, which we would block this way, buuuut that seems far fetched.) So it seems like a relatively safe choice, even if nullable is annoying of course.

@mhsdesign
Copy link
Member

@kitsunet its not tooo far fetched: #5154 i stumbled already upon that unsetting default values does NOT work via initial properties ...

@kitsunet
Copy link
Member

kitsunet commented Jan 20, 2025

I still think this is a mistake and we should allow empty event sets 🤷 Instead of trying to fix it at the source (which might not even know without expensive checks if an event would result)

@mhsdesign
Copy link
Member

Hmm with the followup in #5396 which leverages heavily phpstan to ensure no empty evens are ever published, im positive that we can go down this road and i do like the new strictness and it definitely makes sense that each command results in at least one event also in light that we want to prevent noops for publish and rebase on the lover level: #5337

@kitsunet
Copy link
Member

I think it's weird to expect the command issuers to effectively know if something would result in an event or not.... But yeah lets go with this for now, we can always get more loose again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants