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

Drush 10 / Symfony 6 compatibility #5108

Merged
merged 1 commit into from Apr 2, 2022
Merged

Conversation

greg-1-anderson
Copy link
Member

@greg-1-anderson greg-1-anderson commented Mar 30, 2022

Symfony 6 changed the method signature in a number of classes that we extend. It is therefore not possible for us to use the same source file with both Symfony 6 and Symfony 4/5. However, we do not want to have a different Drush executable for Drupal 9 and Drupal 10.

To get around these seemingly incompatible goals, we introduce a dynamic class loader, that will bring in a different set of sources for different major versions of Symfony. We use the Symfony 4 sources with Symfony 4 and 5, because they are compatible. Symfony 5 is only used in early versions of Drupal 10, though, so perhaps we do not need to support it long term.

@@ -42,7 +42,7 @@ public function example()
*
* @hook init sut:simple
*/
public function customLogger(DrushArgvInput $argv, AnnotationData $annotationData): void
public function customLogger(ArgvInput $argv, AnnotationData $annotationData): void
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 we have a breaking change here (which hooks are affected?). Just noting it for release notes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this is a breaking change. If it is, we can put back DrushArgvInput and make it an empty extension of ArgvInput.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess at a minimum this is a breaking change for anyone who copied DrushArgvInput from this code into their hook. I think that technically, though, using DrushArgvInput or even ArgvInput as I have here is a bug. It should be InputInterface, so that there isn't a type error if a non-ArgvInput $input is injected. I don't think it's possible for $input to be incompatible with ArgvInput, but it will be incompatible with DrushArgvInput if --strict=0 is used.

Maybe worth putting into the release notes, but I don't think it's absolutely necessary to maintain b/c in Drush 11. If you want to, though, we can do what I said above and put an empty DrushArgvInput class for Drush 11, and remove in 12. That's pretty low effort / low impact, and the most conservative thing to do.

@benjifisher
Copy link

I think I ran into this problem. Let me help the search engines direct people to this page:

PHP Fatal error:  Declaration of Drush\Symfony\DrushArgvInput::getFirstArgument() must be compatible with Symfony\Component\Console\Input\ArgvInput::getFirstArgument(): ?string

As a work-around, I hacked Drupal's core/composer.json to allow symfony/console:^5.0, then required that version. I am not proud.

@greg-1-anderson greg-1-anderson force-pushed the remove-drush-argv-input branch 2 times, most recently from 5c320b6 to 38c5883 Compare April 1, 2022 22:14
@greg-1-anderson
Copy link
Member Author

All green, just a little more cleanup to do.

@greg-1-anderson greg-1-anderson changed the title Remove DrushArgvInput Drush 10 / Symfony 6 compatibility Apr 1, 2022
@greg-1-anderson greg-1-anderson marked this pull request as ready for review April 2, 2022 00:03
@greg-1-anderson greg-1-anderson marked this pull request as draft April 2, 2022 00:03
@greg-1-anderson
Copy link
Member Author

Found another thing.

@greg-1-anderson greg-1-anderson marked this pull request as ready for review April 2, 2022 00:36
@greg-1-anderson
Copy link
Member Author

Squashed and rebased with HEAD of 11.x.

Copy link
Member

@weitzman weitzman left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks.

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.

None yet

3 participants