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 deprecations for commands while maintian lazyness #849

Conversation

jordisala1991
Copy link
Member

@jordisala1991 jordisala1991 commented Jun 25, 2022

Subject

I am targeting this branch, because this is BC.

Changelog

### Removed
- Avoid deprecations for console commands on Symfony 6.1.

@jordisala1991 jordisala1991 changed the title Allow doctrine persistence 3.0 and fix deprecations for commands while maintian lazyness Fix deprecations for commands while maintian lazyness Jun 25, 2022
@jordisala1991 jordisala1991 added patch and removed minor labels Jun 25, 2022
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'sonata:classification:fix-context', description: 'Generate the default context if none defined and attach the context to all elements')]
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 think this is the correct way to avoid this deprecation, wdyt @VincentLanglet ? In SonataAdminBundle we fixed it different but to me this is more correct since the attribue only gets used on Symfony 6.1, and the older versions can maintain what they have for lazy commands.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer this solution over sonata-project/SonataBlockBundle#1075 or (the SonataAdmin PR).
So the attribute solve the deprecation even if the static property is still used ?

Is there a reason to not doing this on Admin/BlockBundle or can we update the code too ?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can update that code too.

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'sonata:classification:fix-context', description: 'Generate the default context if none defined and attach the context to all elements')]
Copy link
Member

Choose a reason for hiding this comment

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

I prefer this solution over sonata-project/SonataBlockBundle#1075 or (the SonataAdmin PR).
So the attribute solve the deprecation even if the static property is still used ?

Is there a reason to not doing this on Admin/BlockBundle or can we update the code too ?

Copy link
Member

@franmomu franmomu left a comment

Choose a reason for hiding this comment

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

I'm fine with this way too, I did that way to not have to change code when dropping versions.

final class FixContextCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 6.0 is dropped.
Copy link
Member

Choose a reason for hiding this comment

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

I guess this can be removed when dropping support for Symfony < 5.4

Copy link
Member Author

Choose a reason for hiding this comment

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

The attribute was introduced at 6.0. So it is better to remove both at 6.0.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, and maybe is not correct documented, but the change where they make the AsCommand load lazy is on 6.0

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems like you are right even though it is not documented. Will try to update those indications on next pR.

@jordisala1991 jordisala1991 merged commit 1c0a839 into sonata-project:4.x Jun 25, 2022
@jordisala1991 jordisala1991 deleted the feature/add-doctrine-persistence-3.0 branch June 25, 2022 09:17
@VincentLanglet
Copy link
Member

Can you do the PR for SonataAdmin and SonataBlock ? @jordisala1991

@jordisala1991
Copy link
Member Author

Yes, you do know if there are other bundles with commands?

@VincentLanglet
Copy link
Member

Yes, you do know if there are other bundles with commands?

Only
https://github.com/sonata-project/SonataSeoBundle/tree/3.x/src/Command
and pagebundle. (but doesn't support SF5 yet)

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

Successfully merging this pull request may close these issues.

None yet

3 participants