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

Allow Symfony 7, dropped support for 4.4 and bumped minimal version to 5.4 #324

Merged
merged 6 commits into from
Jan 10, 2024

Conversation

evertharmeling
Copy link
Contributor

No description provided.

@yann-eugone
Copy link
Member

Hello, first of all, thank you for your contribution
Can you explain why you wish we drop support for older php/symfony versions ?
Is there something that is not working in your cases ?

@evertharmeling
Copy link
Contributor Author

Hi Yann,

Thanks for your response! Main thing is that Symfony 4.4 isn't maintained anymore, security fixes end this month, also see the overview of all supported versions.

Next to that the adjustment in src/Messenger/DumpSitemapMessageHandler.php would be much more complicated to fix as the AsMessageHandler attribute is introduced in Symfony 5.4.
Supporting both the interface MessageHandlerInterface (not being available in Symfony >=7.0) and the attribute AsMessageHandler (not being available in Symfony <5.3) would require some (unwanted) hacks. Dropping support for 4.4 solves this problem.

So all in all I think this justifies dropping the support for 4.4. Users who still use that version could easily keep using version 3.3.1 of this bundle.

@yann-eugone
Copy link
Member

I agree
Still, this will require a new major version, so marked this PR as bc break

@evertharmeling
Copy link
Contributor Author

evertharmeling commented Nov 22, 2023

It would not cause a BC break, and wouldn't necessarily require a new major version, as users who are on Symfony 4.4 won't be able to install a newer version of the bundle as they do not meet the requirements (symfony 5.4 and up).

But you could still release a new version if you want. Cheers!

@yann-eugone
Copy link
Member

I see your point
But I still consider dropping support for Symfony versions to be done in a major release
Removing interfaces from classes might also be considered as BC, because you don't know what tools developers might have created on this

Still very appreciated, and will definitely merge it whenever the CI will be green

@evertharmeling
Copy link
Contributor Author

Sure!

I dropped the usage of symfony/framework-extra-bundle as it is deprecated since Symfony 6.2 and incompatible with Symfony >=7.0. AFAIK it was only used for the Route annotations, as PHP attributes are the new best practices but only supported from Symfony >=6.4, I refactored lower versions to make use of Yaml routes.

This should fix the CI build hopefully.

@evertharmeling
Copy link
Contributor Author

Could you approve the workflow Yann, so we at least see if the CI is all fixed now?

@yann-eugone
Copy link
Member

I was sure I approved it... Sorry

@evertharmeling
Copy link
Contributor Author

No problem! I've fixed some tests and now need your approval again :). Hopefully the suite passes for all versions now.

@evertharmeling evertharmeling force-pushed the sf-7 branch 2 times, most recently from 02a598a to 897fa18 Compare December 1, 2023 11:36
@evertharmeling
Copy link
Contributor Author

evertharmeling commented Dec 1, 2023

Hmm they changed the return type of KernelTestCase::getContainer() from ContainerInterface to Container (see). Used in SitemapTestCase.

Not really sure how we may bypass this easily...

EDIT: maybe the same solution as done with Kernel :), let me see

Alright looks like this could work, could you approve the workflow once again :)

@evertharmeling evertharmeling force-pushed the sf-7 branch 3 times, most recently from 82ae974 to e6b9f38 Compare December 1, 2023 11:49
@@ -0,0 +1,26 @@
archive:
Copy link
Member

Choose a reason for hiding this comment

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

what are these tests/Integration/config/*/routes/controllers.yaml files for ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I dropped the usage of sensio/framework-extra-bundle which is also 'end-of-life' since Syfmony 6.2 (see).

I had to refactor the use of routing annotations (which was part of that bundle), and as routing attributes are not supported on lower versions I refactored the routing annotations to yaml routing config. So these controllers.yaml files contain the yaml routing definitions.

Copy link
Member

Choose a reason for hiding this comment

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

So it means that we are not able to test that on symfony 5.4 the bundle is still able to work with annotation
This might be an issue IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We aren't explicitly testing Route-annotations anymore indeed, but the only change made is the way the routing is defined. Both of the syntaxes result in the same underlying Route-object.

For example

/**
 * @Route("/blog", name="blog_read", options={"sitemap"={"section"="blog"}})
*/

Is simply rewritten to the Yaml syntax

blog_read:
    path: /blog
    controller: Presta\SitemapBundle\Tests\Integration\Controller\BlogController::read
    options:
        sitemap:
            section: blog

Since the bundle (sensio/framework-extra-bundle) is abandoned, it's very unlikely that the currently used syntax wouldn't work anymore (for projects using Symfony <6.3). And even if it would turn out to be erroneous it would be related to the same code in symfony/routing as the Yaml or Attribute syntax uses and thus be still supported in our testsuite.

If we would have had an own Annotation-route class depending on the bundle above that would be something different, the defined 'options' we use are just part of the same code as before.

So we are not compromising on our testsuite, we just use an alternative syntax to define the same arrangement to build the testsuite.

Copy link
Member

Choose a reason for hiding this comment

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

Hi evertharmeling,
First of all thank you for your contribution, this is really great!

I'm confused here: why would you remove the @Route annotations? I understand that the sensio/framework-extra-bundle is abandonned, but I'm pretty sure the annotations we are talking about are Symfony's ones, right?

Looking at the diff here and here, you will notice that you didn't have to remove any import and that the imported Route comes from Symfony's namespace.

If I'm correct, maybe we could keep the annotations as it's a valid way to declare a route in the latest Symfony versions.
What do you think?

Copy link
Contributor Author

@evertharmeling evertharmeling Dec 8, 2023

Choose a reason for hiding this comment

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

Hi Benoit,

Thanks for reaching out, first of all I never used annotations to configure my routes myself, so I had to dive into it all too, and this is what I got out of it.

You both are right. sorry for my stubbornness , I went off-track with the notification on the SensioFrameworkExtraBundle docs, and mistakenly assumed Annotations were completely dropped in higher versions, which would make still supporting it on all versions problematic.

It's no longer recommended to use this bundle in current Symfony applications. All the annotations provided by this bundle are now built-in in Symfony as PHP attributes. Check out the full list of Symfony attributes.

They don't mention Annotations are still supported, but here they do :)

I've reverted the changes and it looks like the tests still pass.

Things to note:

  • if I'm correct we are now only testing the Annotations routes on Symfony 5.4 and PHP < 8.0, hence the check in Kernel.php

Let's see if the whole workflow still passes 🤞

Copy link
Member

Choose a reason for hiding this comment

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

No worries, it's quite confusing anyway that Symfony started to use the same @Route annotation's name in replacement of Sensio's one.

Here is the trick:

-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Component\Routing\Annotation\Route;

The first import comes from Sensio's bundle and is deprecated, the second one comes from Symfony and is perfectly valid to be used as annotation @Route or attribute #[Route].

Thank you for having taken this into account 🙂

@evertharmeling evertharmeling force-pushed the sf-7 branch 3 times, most recently from 6667700 to ac5b258 Compare December 8, 2023 14:06
@evertharmeling
Copy link
Contributor Author

Ah sorry I seem to have messed up the contents of the /special/annotations.yaml file, fixed it. One last time approving the workflow 🤞

@dkarlovi
Copy link

dkarlovi commented Dec 8, 2023

@yann-eugone

I still consider dropping support for Symfony versions to be done in a major release

This is typically not the case, dropping support for specific dependencies is not a breaking change because the users of the dropped dependency will not get the new package offered, no?

when we drop support for an older version of PHP, composer will not consider the new version if the PHP version requirement is no longer fulfilled. Thus, you won't end up with a fatal error due to a wrong method signature, you just won't get the new version.

You don't need to release a major version just to stop supporting an old dep version.

@yann-eugone
Copy link
Member

yann-eugone commented Dec 13, 2023

@dkarlovi sure, I've understand this point of view
I believe everyone is free to deal with this kind of problem the way they want, I understand why Doctrine is doing it like it, and that's OK
But as you can see in the first paragraph of the link you provided

Since many people are encountering issues with these updates ...

And here is the issue : people complains for almost anything
As a maintainer of package, I want to be clear what the contract are when using the bundle
And to me, it's very clear that :

  • dropping version of a package
  • dropping compatibility with a package
  • dropping compatibility with a feature of a package

Remains a BC

Copy link
Member

@yann-eugone yann-eugone left a comment

Choose a reason for hiding this comment

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

@evertharmeling thank you for your help, your efforts, and everything else

@yann-eugone yann-eugone changed the base branch from 3.x to 4.x December 13, 2023 16:03
@yann-eugone yann-eugone changed the base branch from 4.x to 3.x December 13, 2023 16:03
@yann-eugone
Copy link
Member

hmmm ok I've missed something
We already have a 4.x branch, and these devs here should have been done on that branch
do you want to rebase your branch @evertharmeling ?

@evertharmeling
Copy link
Contributor Author

evertharmeling commented Dec 13, 2023

@yann-eugone done!

No problem, glad I could be of help! Thanks for your help and patience!

@Valmonzo
Copy link

Hello, what is missing to merge this PR ? Any helps needed ?

@shmshd
Copy link

shmshd commented Jan 4, 2024

@yann-eugone, just wondering if there's any particular reason for the delay in merging this PR?

@yann-eugone
Copy link
Member

I was unavailable for some holidays 🎄

Unfortunately, it seems that the rebase of that branch picked some commits we don't want.
image
These are commits added to the 3.x branch for the upgrade path to 4.x.

I understand this is partially my fault, because I didn't told you this from the beginning you targeted the wrong branch, still, these commits must be dropped in order for that PR to be merged.

@evertharmeling
Copy link
Contributor Author

Sorry missed the commits popped in, I removed them and it should be fixed now! @yann-eugone could you approve the workflow once again?

@yann-eugone
Copy link
Member

Thank you for your help, very much appreciated

@yann-eugone yann-eugone merged commit 6c5d03d into prestaconcept:4.x Jan 10, 2024
7 checks passed
@evertharmeling
Copy link
Contributor Author

No problem, glad to be of help! Thanks for the feedback and assistance!

@CoalaJoe
Copy link

Thanks for the work guys! Is there a release already planned containing these changes?

@yann-eugone
Copy link
Member

Not yet, the next major version will take some time to be tested

You can help by requiring the dev version on your projects

composer require presta/sitemap-bundle:4.x-dev@dev

And provide feedback by opening issues if something fails

@Valmonzo
Copy link

Thx for your works guys !

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.

7 participants