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

Remove deprecated code #1417

Closed
15 of 17 tasks
Tracked by #1416
eerison opened this issue Apr 22, 2022 · 36 comments
Closed
15 of 17 tasks
Tracked by #1416

Remove deprecated code #1417

eerison opened this issue Apr 22, 2022 · 36 comments
Labels
Milestone

Comments

@eerison
Copy link
Contributor

eerison commented Apr 22, 2022

⚠️ Deprecations that need to be solved for Symfony 5 upgrade.

Note
those deprecations are waiting for this PR sonata-project/SonataAdminBundle#7867

Remaining direct deprecation notices (6)

  • Allow to configure routeName and routePattern dynamically SonataAdminBundle#7867 1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBaseRoutePattern()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\SharedBlockAdmin".
    1x in BaseBlockAdminTest::testSettingAsEditedOnPreBatchDeleteAction from Sonata\PageBundle\Tests\Admin

  • Allow to configure routeName and routePattern dynamically SonataAdminBundle#7867 1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBaseRouteName()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\SharedBlockAdmin".
    1x in BaseBlockAdminTest::testSettingAsEditedOnPreBatchDeleteAction from Sonata\PageBundle\Tests\Admin

  • Upgrade Sonatablock and SonataSeo #1483 1x: The "Sonata\BlockBundle\Block\BlockContextManager" class is considered final since sonata-project/block-bundle 3.0. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Block\BlockContextManager".
    1x in BlockContextManagerTest::testGetWithValidData from Sonata\PageBundle\Tests\Block

  • Upgrade Sonatablock and SonataSeo #1483 1x: The "Sonata\BlockBundle\Block\Service\ContainerBlockService" class is considered final since sonata-project/block-bundle 3.0. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Block\ContainerBlockService".
    1x in ContainerBlockServiceTest::testExecute from Sonata\PageBundle\Tests\Block

  • Feature/1415/Decouple notification-bundle from cleanup snapshot #1434 1x: The "Sonata\PageBundle\Command\BaseCommand" class extends "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" that is deprecated since Symfony 4.2, use {@see Command} instead.
    1x in BaseBlockAdminTest::testSettingAsEditedOnPreBatchDeleteAction from Sonata\PageBundle\Tests\Admin

  • SnapshotManager: use QueryBuilder #1446 1x: The "Sonata\Doctrine\Entity\BaseEntityManager::getConnection()" method is deprecated since sonata-project/sonata-doctrine-extensions 1.15 and will be removed in version 2.0. Use "getEntityManager()->getConnection()" instead.
    1x in SnapshotManagerTest::testEnableSnapshots from Sonata\PageBundle\Tests\Entity

  • remove symfony/debug dependency #1429 8x: The "Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent::getException()" method is deprecated since Symfony 4.4, use "getThrowable()" instead.
    4x in ExceptionListenerTest::testInternalException from Sonata\PageBundle\Tests\Listener
    3x in ExceptionListenerTest::testNotFoundException from Sonata\PageBundle\Tests\Listener
    1x in ExceptionListenerTest::testNotFoundExceptionInEditorMode from Sonata\PageBundle\Tests\Listener

  • 6x: The Sonata\AdminBundle\Admin\AbstractAdmin::trans method is deprecated since version 3.9 and will be removed in 4.0.

  • Fixes Validator Testcase #1437 2x: Passing a null message when instantiating a "Symfony\Component\Validator\ConstraintViolation" is deprecated since Symfony 4.4.
    1x in UniqueUrlValidatorTest::testValidateWithPageFound from Sonata\PageBundle\Tests\Validator
    1x in UniqueUrlValidatorTest::testValidateWithRootUrlAndNoParent from Sonata\PageBundle\Tests\Validator

  • 1x: The Sonata\BlockBundle\Test\AbstractBlockServiceTestCase class is deprecated since sonata-project/block-bundle 3.16 and will be removed with the 4.0 release. Use Sonata\BlockBundle\Test\BlockServiceTestCase instead.
    1x in ClassLoader::loadClass from Composer\Autoload

  • 1x: Not passing argument 2 to "Sonata\AdminBundle\Admin\AbstractAdmin::setParent()" is deprecated since sonata-project/admin-bundle 3.103 and will not be allowed in 4.0.
    1x in BaseBlockAdminTest::testSettingAsEditedOnPreBatchDeleteAction from Sonata\PageBundle\Tests\Admin

  • 1x: You are trying to set entity an instance of "Mock_PageInterface_4fbe8eb3",
    which is not the one registered with this admin class ("Sonata\PageBundle\Tests\Model\Page").
    This is deprecated since 3.5 and will no longer be supported in 4.0.
    1x in PageAdminTest::testTabMenuHasLinksWithSubSite from Sonata\PageBundle\Tests\Admin

  • 1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::buildTabMenu()" method is deprecated since sonata-project/admin-bundle 3.95 and will be removed in version 4.0.
    1x in PageAdminTest::testTabMenuHasLinksWithSubSite from Sonata\PageBundle\Tests\Admin

  • 1x: The default value of the "$secure" and "$samesite" arguments of "Symfony\Component\HttpFoundation\Cookie::__construct"'s constructor will respectively change from "false" to "null" and from "null" to "lax" in Symfony 5.0, you should define their values explicitly or use "Cookie::create()" instead.
    1x in ResponseListenerTest::testPageIsEditor from Sonata\PageBundle\Tests\Listener

Deprecations related with bundles.

  • 1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBatchActions()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\PageAdmin".
  • 1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBatchActions()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\SnapshotAdmin".
    1x in CreateSnapshotsCommandTest::setUp from Sonata\PageBundle\Tests\Command
    1x in SnapshotManagerTest::testEnableSnapshots from Sonata\PageBundle\Tests\Entity
  • PageExtension without deprecated InitRuntimeInterface #1436 1x: The "Sonata\PageBundle\Twig\Extension\PageExtension" class implements "Twig\Extension\InitRuntimeInterface" that is deprecated since Twig 2.7, to be removed in 3.0.
    1x in Issue1134Test::testLabelInShowAction from Sonata\PageBundle\Tests\Functional\Ticket

Warning
if you going to work in one of those deprecations, say which one you will get before start, to avoid more the one guy work in the same thing!

@VincentLanglet VincentLanglet added this to the 4.0 milestone Apr 22, 2022
@Hanmac
Copy link
Contributor

Hanmac commented Jul 7, 2022

"Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent::getException()" method is deprecated since Symfony 4.4, use "getThrowable()"

is getting fixed by this: #1429

@Hanmac
Copy link
Contributor

Hanmac commented Jul 8, 2022

The "Sonata\PageBundle\Twig\Extension\PageExtension" class implements "Twig\Extension\InitRuntimeInterface" that is deprecated since Twig 2.7, to be removed in 3.0.

isn't fixed by #1423 but will be by #1436

@eerison
Copy link
Contributor Author

eerison commented Jul 8, 2022

The "Sonata\PageBundle\Twig\Extension\PageExtension" class implements "Twig\Extension\InitRuntimeInterface" that is deprecated since Twig 2.7, to be removed in 3.0.

isn't fixed by #1423 but will be by #1436

Ok I changed ;) Thanks :)

@Hanmac
Copy link
Contributor

Hanmac commented Jul 9, 2022

2x: Passing a null message when instantiating a "Symfony\Component\Validator\ConstraintViolation" is deprecated since Symfony 4.4.
1x in UniqueUrlValidatorTest::testValidateWithPageFound from Sonata\PageBundle\Tests\Validator
1x in UniqueUrlValidatorTest::testValidateWithRootUrlAndNoParent from Sonata\PageBundle\Tests\Validator

will be fixed by this: #1437

The Translator was the culprit

@Hanmac
Copy link
Contributor

Hanmac commented Jul 9, 2022

@VincentLanglet how do i fix these two?

1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBaseRoutePattern()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\SharedBlockAdmin".
1x in CreateSnapshotsCommandTest::setUp from Sonata\PageBundle\Tests\Command
1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBaseRouteName()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\SharedBlockAdmin".

caused by this:

public function getBaseRoutePattern()
{
return sprintf('%s/%s', parent::getBaseRoutePattern(), 'shared');
}
public function getBaseRouteName()
{
return sprintf('%s/%s', parent::getBaseRouteName(), 'shared');
}

because these are "would be" final, i can't overwrite them like that, and if i would try to set them later, i can't overwrite the cached values?

@VincentLanglet
Copy link
Member

You can override directly the protected variable
https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Admin/AbstractAdmin.php#L112-L119

Can't it do the job ?

@Hanmac
Copy link
Contributor

Hanmac commented Jul 10, 2022

You can override directly the protected variable https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Admin/AbstractAdmin.php#L112-L119

Can't it do the job ?

Yes I could set these but that doesn't work like the current function

Because BaseBlockAdmin doesn't set these values they need to be calculated from class. And when they do, the cache values are set. Now setting the variable doesn't change anything because of the cache ones.

for example i tried this:

    public function configure()
    {
        $this->baseRoutePattern = sprintf('%s/%s', $this->getBaseRoutePattern(), 'shared');
        $this->baseRouteName = sprintf('%s/%s', $this->getBaseRouteName(), 'shared');
    }

which doesn't work because of cached values

@VincentLanglet
Copy link
Member

Ok, I have some questions

  • What are the current values of routePattern and routeName with the override ? I see it's %s/shared but I need to know the whole value to understand why we can't reproduce it with
protected $baseRoutePattern = 'foo/shared`
protected $baseRouteName = 'foo/shared`
  • Why does it matter to suffix this with shared ? Can't we just remove the override and let the default behavior ? This is weird for instance to have a / in the baseRouteName, everywhere else we use _.

It will help me to find the best solutions.

@Hanmac
Copy link
Contributor

Hanmac commented Jul 10, 2022

Ok, I have some questions

* What are the current values of routePattern and routeName with the override ? I see it's `%s/shared` but I need to know the whole value to understand why we can't reproduce it with
protected $baseRoutePattern = 'foo/shared`
protected $baseRouteName = 'foo/shared`
* Why does it matter to suffix this with `shared` ? Can't we just remove the override and let the default behavior ? This is weird for instance to have a `/` in the baseRouteName, everywhere else we use `_`.

It will help me to find the best solutions.

the thing is done using %sonata.page.admin.block.entity% parameter for class and getting the dynamic part, then it uses the function above and adds /shared to it

for why it does it to not collide with the other page admin that uses the same entity as class

@VincentLanglet
Copy link
Member

I currently doesn't see a better way than
sonata-project/SonataAdminBundle#7867
which would allow the override in PageBundle.

WDYT @jordisala1991 ?

@Hanmac
Copy link
Contributor

Hanmac commented Jul 11, 2022

i need to run the tests for this again, but the only thing i see are the big Twig change
and the Command + Services change.

and both of them already got PRs

@VincentLanglet
Copy link
Member

IMHO the command PR need to be restarted since we plan to

For twig there is some changes needed #1423

And if you want to help to find a solution, there is this issue #1442

@Hanmac
Copy link
Contributor

Hanmac commented Jul 11, 2022

1x: The "Sonata\Doctrine\Entity\BaseEntityManager::getConnection()" method is deprecated since sonata-project/sonata-doctrine-extensions 1.15 and will be removed in version 2.0. Use "getEntityManager()->getConnection()" instead.
1x in SnapshotManagerTest::testEnableSnapshots from Sonata\PageBundle\Tests\Entity

hm the snapshotmanager uses sql instead of dql or query builder
i will see if i can make that better

@VincentLanglet
Copy link
Member

On Sql/dql there is this issue #1426 dunno if it's the same subject.

@Hanmac
Copy link
Contributor

Hanmac commented Jul 11, 2022

yeah partly, but also the enable snapshots query

@eerison
Copy link
Contributor Author

eerison commented Jul 11, 2022

IMHO the command PR need to be restarted since we plan to

For twig there is some changes needed #1423

And if you want to help to find a solution, there is this issue #1442

I'm deprecating the baseCommand in my Pull request ;)

@eerison
Copy link
Contributor Author

eerison commented Jul 13, 2022

Ok I checked again the 4.x branch and I can see only 6 direct deprecation that is a impediment to support Symfony 5 and sonata 4

@VincentLanglet
Copy link
Member

The first two will need something like this on SonataAdmin 4 sonata-project/SonataAdminBundle#7867

@Hanmac
Copy link
Contributor

Hanmac commented Jul 13, 2022

The "Sonata\Doctrine\Entity\BaseEntityManager::getConnection()"

the Connection thing is part of the Query rework I'm trying to do, i just need to write better testcases

#1446

@Hanmac
Copy link
Contributor

Hanmac commented Jul 13, 2022

1x: The "Sonata\BlockBundle\Block\BlockContextManager" class is considered final since sonata-project/block-bundle 3.0. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Block\BlockContextManager".
1x in BlockContextManagerTest::testGetWithValidData from Sonata\PageBundle\Tests\Block

1x: The "Sonata\BlockBundle\Block\Service\ContainerBlockService" class is considered final since sonata-project/block-bundle 3.0. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Block\ContainerBlockService".
1x in ContainerBlockServiceTest::testExecute from Sonata\PageBundle\Tests\Block

what to do with these two? the blockbundle ones can't be extended anymore. Are the page bundle ones really needed?

otherwise i will think about something

@VincentLanglet
Copy link
Member

For the second class,

  • the first method we're doing the same thing than in BlockBundle
  • the second method we're just overriding the 'SonataBlockBundle' value.
    But since the method is/are public we can use decoration/injection instead of extension

For the first class, the simpler solution I see is to provide an AbstractBlockContextManager in BlockBundle with everything final except protected configureSettings. Then it will be extended by BlockBundle and PageBundle differently.

@Hanmac
Copy link
Contributor

Hanmac commented Jul 13, 2022

yeah i was thinking about decoration too

also PageBundle still points to 3.x Block Bundle and not 4.x, but that might be work for another PR

@VincentLanglet
Copy link
Member

yeah i was thinking about decoration too

also PageBundle still points to 3.x Block Bundle and not 4.x, but that might be work for another PR

Two solutions:

  • Doing the PR on BlockBundle 3.x, doing a release, and solving the deprecation
  • Doing the PR on BlockBundle 4.x, doing a release and solving the issue in the same time we bump to blockBundle 4.

If it's not too much work, I prefer the second solution, this avoid a release on an old branch.

@VincentLanglet
Copy link
Member

Seems like there is #1448 for the block deprecations.
Help on the review is appreciated @Hanmac :)

@jordisala1991
Copy link
Member

    public function configure()
    {
        $this->baseRoutePattern = sprintf('%s/%s', $this->getBaseRoutePattern(), 'shared');
        $this->baseRouteName = sprintf('%s/%s', $this->getBaseRouteName(), 'shared');
    }

What about:

    public function configure()
    {
        $this->baseRoutePattern = sprintf('%s/%s', parent::getBaseRoutePattern(), 'shared');
        $this->baseRouteName = sprintf('%s/%s', parent::getBaseRouteName(), 'shared');
    }

Can you try with that? @Hanmac

@Hanmac
Copy link
Contributor

Hanmac commented Jul 15, 2022

    public function configure()
    {
        $this->baseRoutePattern = sprintf('%s/%s', $this->getBaseRoutePattern(), 'shared');
        $this->baseRouteName = sprintf('%s/%s', $this->getBaseRouteName(), 'shared');
    }

What about:

    public function configure()
    {
        $this->baseRoutePattern = sprintf('%s/%s', parent::getBaseRoutePattern(), 'shared');
        $this->baseRouteName = sprintf('%s/%s', parent::getBaseRouteName(), 'shared');
    }

Can you try with that? @Hanmac

i didn't tried yet, but it doesn't work because calling getBaseRoutePattern would cache the result and then setting baseRoutePattern wouldn't have any effect

@jordisala1991
Copy link
Member

I just tried, it cant be done without the Pr opened by @VincentLanglet . So this deprecation will be only fixed on 4.x

@eerison
Copy link
Contributor Author

eerison commented Jul 18, 2022

I will work on those two deprecations

#1470 1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBaseRoutePattern()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\SharedBlockAdmin".
1x in BaseBlockAdminTest::testSettingAsEditedOnPreBatchDeleteAction from Sonata\PageBundle\Tests\Admin

#1470 1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBaseRouteName()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\SharedBlockAdmin".
1x in BaseBlockAdminTest::testSettingAsEditedOnPreBatchDeleteAction from Sonata\PageBundle\Tests\Admin

@eerison
Copy link
Contributor Author

eerison commented Jul 18, 2022

I just tried, it cant be done without the Pr opened by @VincentLanglet . So this deprecation will be only fixed on 4.x

tried what? I don't get it!

@VincentLanglet
Copy link
Member

I just tried, it cant be done without the Pr opened by @VincentLanglet . So this deprecation will be only fixed on 4.x

tried what? I don't get it!

You currently cannot solve the deprecations, we need to finish and release sonata-project/SonataAdminBundle#7867. And this will only be solve in 4.x.

The issue is that you cannot override

    public function getBaseRoutePattern()
    {
        return sprintf('%s/%s', parent::getBaseRoutePattern(), 'shared');
    }
    public function getBaseRouteName()
    {
        return sprintf('%s/%s', parent::getBaseRouteName(), 'shared');
    }

@eerison
Copy link
Contributor Author

eerison commented Jul 18, 2022

I just tried, it cant be done without the Pr opened by @VincentLanglet . So this deprecation will be only fixed on 4.x

tried what? I don't get it!

You currently cannot solve the deprecations, we need to finish and release sonata-project/SonataAdminBundle#7867. And this will only be solve in 4.x.

The issue is that you cannot override

    public function getBaseRoutePattern()
    {
        return sprintf('%s/%s', parent::getBaseRoutePattern(), 'shared');
    }
    public function getBaseRouteName()
    {
        return sprintf('%s/%s', parent::getBaseRouteName(), 'shared');
    }

Yeah it's the issue, and when this PR pass, should I be able to override getBaseRoutePattern?

Edit 1: and your PR will fix all those deprecations that are missing?

@Hanmac
Copy link
Contributor

Hanmac commented Jul 18, 2022

1x: The "Sonata\BlockBundle\Block\BlockContextManager" class is considered final since sonata-project/block-bundle 3.0. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Block\BlockContextManager".
1x in BlockContextManagerTest::testGetWithValidData from Sonata\PageBundle\Tests\Block
1x: The "Sonata\BlockBundle\Block\Service\ContainerBlockService" class is considered final since sonata-project/block-bundle 3.0. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Block\ContainerBlockService".
1x in ContainerBlockServiceTest::testExecute from Sonata\PageBundle\Tests\Block

this will be fixed by #1448

@VincentLanglet
Copy link
Member

Yeah it's the issue, and when this PR pass, should I be able to override getBaseRoutePattern?

You'll be able to override generateBaseRoutePattern. But only in the same PR than the one which bump the SonataAdmin dependency. So it's all or nothing.

@eerison
Copy link
Contributor Author

eerison commented Jul 22, 2022

I guess it's just missing to add sonata admin 4 to solve this deprecation

1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBaseRoutePattern()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\SharedBlockAdmin".
1x in BaseBlockAdminTest::testSettingAsEditedOnPreBatchDeleteAction from Sonata\PageBundle\Tests\Admin

@VincentLanglet
Copy link
Member

It requires a SonataAdmin release first.

@VincentLanglet
Copy link
Member

I guess it's just missing to add sonata admin 4 to solve this deprecation

1x: The "Sonata\AdminBundle\Admin\AbstractAdmin::getBaseRoutePattern()" method is considered final since sonata-project/admin-bundle 3.102. It may change without further notice as of its next major version. You should not extend it from "Sonata\PageBundle\Admin\SharedBlockAdmin".
1x in BaseBlockAdminTest::testSettingAsEditedOnPreBatchDeleteAction from Sonata\PageBundle\Tests\Admin

Will be done with #1485 so we can be close this

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

No branches or pull requests

4 participants