Skip to content

[Workflow] Fixed marking state on leave and enter events #21793

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

Merged
merged 1 commit into from
Mar 8, 2017

Conversation

HeahDude
Copy link
Contributor

Q A
Branch? 3.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR related to symfony/symfony-docs#7528

It seems weird to me to dispatch an event while the marking is not yet marked by the new places.
The event is still "marked" by old places when leaving occurs, my guess is that the symmetry should be mirrored.

Do you agree? Should I add a test?

@HeahDude
Copy link
Contributor Author

@stof @lyrixx, what do you think of this? I've pushed a second commit to preserve the original order of the events.

I would also note that the marking has lost its original places for very specific "leave" events, but at this stage it may be ok to only deal with the last part of the event name or should this be fixed too?

@nicolas-grekas nicolas-grekas added this to the 3.2 milestone Feb 28, 2017
@fabpot
Copy link
Member

fabpot commented Mar 1, 2017

ping @lyrixx

@@ -254,17 +254,18 @@ private function transition($subject, Transition $transition, Marking $marking)

private function enter($subject, Transition $transition, Marking $marking)
{
$entered = array();
Copy link
Member

Choose a reason for hiding this comment

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

This array is useless.

Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

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

I really fail to see what is the real issue here: People relies on the event name, not the current marking.
More over it's a kind of BC.
Finally, if you update this method you have to update others method to mimic this behaviour.
So for me it's a 👎 is this state.

@xabbuh
Copy link
Member

xabbuh commented Mar 3, 2017

@HeahDude You said this is supposed to fix a bug. If you, can you add a test case that clarifies the behaviour you expected? As for now I tend to agree with @lyrixx that there is nothing to fix.

@HeahDude HeahDude force-pushed the fix/workflow-enter branch from 2bb1017 to 01ffe81 Compare March 5, 2017 23:21
@HeahDude
Copy link
Contributor Author

HeahDude commented Mar 5, 2017

I've updated the PR with a first commit that adds failing tests, please look at it separately as it marks the ones actually failing without the following patches.

Then I'll try to both clarify what I stated before and to answer @lyrixx's comment:

I really fail to see what is the real issue here: People relies on the event name, not the current marking.

Ok, anyway the marking is available as part of the event object and its state should be consistent during the cycle of the workflow. Currently only the transition event is.

Events are not all named and when multiple places are left or entered the information may be lost at some point.

More over it's a kind of BC.

Every bug fix is a kind of BC break, more or less, since a thing that was happening doesn't anymore.

Finally, if you update this method you have to update others method to mimic this behaviour.

I take that as a "yes" to what I said above:

I would also note that the marking has lost its original places for very specific "leave" events, but at this stage it may be ok to only deal with the last part of the event name or should this be fixed too?

Hence the new third commit of this PR to fix the "leave" related events.

I have no hard feeling about this, but while documenting it in the docs PR linked in the description, it felt just weird to explain it as is.

Thanks for your reviews.

@HeahDude
Copy link
Contributor Author

HeahDude commented Mar 5, 2017

(Tests failure are unrelated).

@@ -254,17 +256,16 @@ private function transition($subject, Transition $transition, Marking $marking)

private function enter($subject, Transition $transition, Marking $marking)
{
foreach ($enter = $transition->getTos() as $place) {
Copy link
Member

Choose a reason for hiding this comment

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

enter -> places ? because right now, it has the same name as the method. It's weird to me. And So update the $from from the leave method to be consistent.

@HeahDude HeahDude force-pushed the fix/workflow-enter branch from 01ffe81 to 083fbd1 Compare March 6, 2017 17:25
@HeahDude
Copy link
Contributor Author

HeahDude commented Mar 6, 2017

Fixed, rebased and squashed!

@HeahDude HeahDude force-pushed the fix/workflow-enter branch 4 times, most recently from 2237b0a to 0fd621c Compare March 7, 2017 13:18
@HeahDude
Copy link
Contributor Author

HeahDude commented Mar 7, 2017

I've just merged @lyrixx patch for tests coding style.

This one should be ready now. Thanks!

@HeahDude HeahDude force-pushed the fix/workflow-enter branch from 0fd621c to 5295be1 Compare March 7, 2017 13:19
@@ -254,17 +256,16 @@ private function transition($subject, Transition $transition, Marking $marking)

private function enter($subject, Transition $transition, Marking $marking)
{
foreach ($places = $transition->getTos() as $place) {
$marking->mark($place);
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit weird to me. The event is named enter and not entered. So for me the event should be dispatched before the actual marking.

Copy link
Member

Choose a reason for hiding this comment

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

I agree (the workflow.entered event was added in #20787 by the way)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've missed that! Thanks

@HeahDude HeahDude force-pushed the fix/workflow-enter branch from 5295be1 to ed1c7a1 Compare March 7, 2017 18:02
@HeahDude
Copy link
Contributor Author

HeahDude commented Mar 7, 2017

Last comments addressed.

@HeahDude HeahDude force-pushed the fix/workflow-enter branch from ed1c7a1 to 175858a Compare March 7, 2017 19:23
@HeahDude HeahDude changed the title [Workflow] Fixed marking state on enter events [Workflow] Fixed marking state on leave and enter events Mar 8, 2017
@lyrixx
Copy link
Member

lyrixx commented Mar 8, 2017

👍

Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

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

👍

@lyrixx
Copy link
Member

lyrixx commented Mar 8, 2017

Thanks Jules.

@lyrixx lyrixx merged commit 175858a into symfony:3.2 Mar 8, 2017
lyrixx added a commit that referenced this pull request Mar 8, 2017
…HeahDude)

This PR was merged into the 3.2 branch.

Discussion
----------

[Workflow] Fixed marking state on leave and enter events

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | related to symfony/symfony-docs#7528

It seems weird to me to dispatch an event while the marking is not yet marked by the new places.
The event is still "marked" by old places when leaving occurs, my guess is that the symmetry should be mirrored.

Do you agree? Should I add a test?

Commits
-------

175858a [Workflow] Fixed marking state on leave and enter events
@HeahDude
Copy link
Contributor Author

HeahDude commented Mar 8, 2017

Thank you for reviewing and merging.

@HeahDude HeahDude deleted the fix/workflow-enter branch March 8, 2017 20:08
@fabpot fabpot mentioned this pull request Mar 9, 2017
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.

6 participants