8000 [Workflow] Fix Event constructor requirements by lyrixx · Pull Request #44642 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Workflow] Fix Event constructor requirements #44642

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
Dec 15, 2021

Conversation

lyrixx
Copy link
Member
@lyrixx lyrixx commented Dec 15, 2021
Q A
Branch? 5.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

This has already been deprecied in 4.x
But while cleaning the 5.x branch, I forgot to apply this patch

See
https://github.com/symfony/symfony/pull/31824/files#diff-5f386ffb0109cc731bd98e63eea021b32faadd98791bd6ba65926d09c5e2ec40L37

More over, Event::getWorkflow() has the correct return type.

@nicolas-grekas
Copy link
Member

Thank you @lyrixx.

@nicolas-grekas nicolas-grekas merged commit 18c7edd into symfony:5.3 Dec 15, 2021
@@ -29,7 +29,7 @@ class Event extends BaseEvent
private $transition;
private $workflow;

public function __construct(object $subject, Marking $marking, Transition $transition = null, WorkflowInterface $workflow = null, array $context = [])
public function __construct(object $subject, Marking $marking, Transition $transition = null, WorkflowInterface $workflow, array $context = [])
Copy link
Member
@derrabus derrabus Dec 15, 2021

Choose a reason for hiding this comment

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

I understand that it was quite unfortunate that we forgot to remove the nullability of the argument after having deprecated passing null. However, this change is problematic:

  • Right now, it is possible to create the object without passing a workflow or setting it to null. You would break that functionality. Then again, actually setting the workflow to null would break getWorkflow(), getWorkflowName() and getMetadata().
  • This change will trigger a warning on PHP 8 because $workflow is mandatory now although it follows an optional parameter $transition.
  • The parameter $transition is effectively mandatory as well now which is a BC break.

Copy link
Member

Choose a reason for hiding this comment

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

Oops, I merged too fast, now reverted. Please submit again @lyrixx

Copy link
Member Author

Choose a reason for hiding this comment

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

Oups, good point !
So we need another round of deprecation ? we need to re-swap all arguments ? 😨

Copy link
Member

Choose a reason for hiding this comment

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

Looks like it. 😢

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe just turning Transition into a mandatory nullable argument rather than swapping.

anyway, I don't expect this constructor to be used a lot in third-party code. This code is expected to listen to events, not to trigger them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or maybe just turning Transition into a mandatory nullable argument rather than swapping.

Not possible, some events are not directly related to transition

Copy link
Member

Choose a reason for hiding this comment

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

Not possible, some events are not directly related to transition

Those events would eplicity pass null as transition then.

anyway, I don't expect this constructor to be used a lot in third-party code. This code is expected to listen to events, not to trigger them.

Me neither. This would mostly affect third party code that extends the workflow component with own logic. But since neither the Event class nor its constructor is flagged as @internal, calling the constructor in third-party code is valid.

Copy link
Member

Choose a reason for hiding this comment

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

but for that code, marking the argument as required or swapping arguments is a BC break in both cases

nicolas-grekas added a commit that referenced this pull request Dec 15, 2021
…yrixx)"

This reverts commit 18c7edd, reversing
changes made to e5d3dea.
nicolas-grekas added a commit that referenced this pull request Dec 15, 2021
* 5.3:
  Revert "minor #44642 [Workflow] Fix Event constructor requirements (lyrixx)"
  Skip transient tests on macos
  [Workflow] Fix Event constructor requirements
  [Translation] Handle the blank-translation in Loco Adapter
  [Serializer] Fix symfony/uid requirement
nicolas-grekas added a commit that referenced this pull request Dec 15, 2021
* 5.4:
  Revert "minor #44642 [Workflow] Fix Event constructor requirements (lyrixx)"
  Skip transient tests on macos
  [Workflow] Fix Event constructor requirements
  [Translation] Handle the blank-translation in Loco Adapter
  [Serializer] Fix symfony/uid requirement
nicolas-grekas added a commit that referenced this pull request Dec 15, 2021
* 6.0:
  Revert "minor #44642 [Workflow] Fix Event constructor requirements (lyrixx)"
  [Workflow] Remove redundant type check
  Skip transient tests on macos
  [Workflow] Fix Event constructor requirements
  [Translation] Handle the blank-translation in Loco Adapter
  [Serializer] Fix symfony/uid requirement
@lyrixx lyrixx deleted the workflow-fix-bad-cleaning branch December 15, 2021 14:57
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.

5 participants
0