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

IBX-8470: Upgraded codebase to Symfony 6 #447

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open

Conversation

alongosz
Copy link
Member

@alongosz alongosz commented Oct 30, 2024

Caution

This is a part of bigger set of changes, to be merged together when ready

  • Remove TMP commits before merge
🎫 Issue IBX-8470

Related PRs:

Description:

ℹ️ Browser tests failure is expected until all OSS packages are upgraded.

Composer packages bump:
  • symfony/* to ^6.4
  • jms/translation-bundle to ^2.4
  • friendsofsymfony/jsrouting-bundle to ^3.5
Essential changes:
  • Declared strict return types for class methods extending/overriding 3rd party packages, that are either already there in bumped version or will be there for sure in the future
  • Aligned strict types for method arguments overriding 3rd party packages
  • Fixed Symfony DI PHP API setDeprecated usage (it will most likely disappear after merging deprecation removal changes)
  • Fixed octal value representation in Yaml (e.g. 0644 -> 0o644)
  • Removed obsolete configuration parameters from Symfony DI semantic config
  • Aligned usage of 3rd party PHP API with the upgraded versions of those packages
  • Aligned tests with both current changes and 3rd party packages changes
  • Replaced usage of deprecated utf8_decode PHP function with mb_convert_encoding
DX:
  • Added strict types to some properties in the vicinity of or related to the upgraded code
    • BinaryFile is an example which gave most trouble due to us relying on uninitialized properties, fixed now
  • Added or fixed PHPDocs
  • Refactored pieces of touched code to be more readable (helping also understanding what's going on there while trying to fix it after the version bump)
  • Improved code quality of tests
Maintenance:
  • [PHPStan] Added to the baseline serializer issues (postponed to SF 7, where PropertyNormalizer is final)
  • [PHPUnit] Configured exact numbers of self, direct, and indirect deprecation to have more control over what's changed.

QA:

TBD if we want to merge it if all green or test everything manually before.

Documentation:

  • Dropped obsolete Ibexa\Core\MVC\Symfony\Security\InteractiveLoginToken. Seems this was some Symfony 2 auth leftover. Mentioned in the User authentication Doc needs to be dropped or changed as well (there should be a task for this already, just wasn't able to find it ATM).
  • Dropped from \Ibexa\Core\MVC\Symfony\Security\UserWrapped obsolete methods: getPassword, getSalt, getUsername and implemented the new one getUserIdentifier.

@alongosz alongosz force-pushed the ibx-8470-symfony-6 branch 2 times, most recently from 568db5c to a1ac641 Compare October 31, 2024 10:49
@alongosz alongosz added Doc needed The changes require some documentation Feature New feature request Work in progress Rebase required labels Oct 31, 2024
@alongosz alongosz force-pushed the ibx-8470-symfony-6 branch 4 times, most recently from 36125d0 to 93ad6ef Compare November 6, 2024 14:48
@alongosz alongosz marked this pull request as ready for review November 7, 2024 09:30
@alongosz alongosz force-pushed the ibx-8470-symfony-6 branch 2 times, most recently from 6440557 to fba6ef0 Compare November 12, 2024 15:02
@alongosz alongosz requested a review from a team November 12, 2024 16:01
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
Comment on lines +49 to +50
$class = $metadataDriverDefinition->getClass();
if (null !== $class && (str_contains($class, 'yml') || str_contains($class, 'xml'))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This raises my eyebrow.

We are checking the class declared for metadata driver. Which means we are, in effect, checking that Doctrine\ORM\Mapping\Driver\YamlDriver contains yml string?

Can you check at runtime what is actually happening here? Since I'm not sure this actually works as intended.

I don't expect us to "fix it" here. But if you're touching this code (I assume since you've seen PHPStan report it) I'd rather have it checked.

Copy link
Member Author

Choose a reason for hiding this comment

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

This raises my eyebrow.

We are checking the class declared for metadata driver. Which means we are, in effect, checking that Doctrine\ORM\Mapping\Driver\YamlDriver contains yml string?

Can you check at runtime what is actually happening here? Since I'm not sure this actually works as intended.

I don't expect us to "fix it" here. But if you're touching this code (I assume since you've seen PHPStan report it) I'd rather have it checked.

I can only guess as the test that is there (\Ibexa\Tests\Bundle\Core\DependencyInjection\Compiler\InjectEntityManagerMappingPassTest) probably checks assumed values. This was an extension point and I wasn't sure how it was used.

Keep in mind that ORM used to allow keeping mappings in either Yaml or XML format. Maybe it's related to that?

I can drop it, but only if you're sure that no longer applies. At runtime OOTB we have only annotation type present.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it can be either XML, YAML or annotations/attributes. It's just that class name would not contain yml string, since the driver is named YamlDriver.

Worst case leave it as is, but it should be checked. It's a potential bug that was probably unnoticed, because majority of projects are using annotations.

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, it can be either XML, YAML or annotations/attributes. It's just that class name would not contain yml string, since the driver is named YamlDriver.

Worst case leave it as is, but it should be checked. It's a potential bug that was probably unnoticed, because majority of projects are using annotations.

@Steveb-p I've checked it more closely now. At runtime there's unresolved parameter there %doctrine.orm.metadata.yml.class% or %doctrine.orm.metadata.xml.class% and that how and why it works. Very unstable, but I'd suggest getting rid of it with doctrine upgrade, since Yml and Xml mappings are deprecated.

Copy link
Contributor

@Steveb-p Steveb-p Dec 12, 2024

Choose a reason for hiding this comment

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

XML mapping is very much alive and kicking, even in 4.0 DBAL (upcoming).

https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/xml-mapping.html#xml-mapping

That being said, I'm okay with leaving it as is for now.

src/bundle/Core/Fragment/DecoratedFragmentRenderer.php Outdated Show resolved Hide resolved
src/bundle/Core/Routing/DefaultRouter.php Outdated Show resolved Hide resolved
src/bundle/Core/Routing/DefaultRouter.php Outdated Show resolved Hide resolved
src/bundle/IO/BinaryStreamResponse.php Show resolved Hide resolved
src/bundle/IO/BinaryStreamResponse.php Outdated Show resolved Hide resolved
src/bundle/IO/BinaryStreamResponse.php Outdated Show resolved Hide resolved
Copy link
Contributor

@konradoboza konradoboza left a comment

Choose a reason for hiding this comment

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

As mentioned in one of my comments below, I would switch more towards constructor property promotion (not necessarily within the scope of this PR).


/**
* Constructor.
* @param array<string, array<string>> $headers An array of response headers
* @param bool $public Files are public by default
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param bool $public Files are public by default
* @param bool $public files are public by default

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, why do we even bother with adding info that is already part of the declaration?

Suggested change
* @param bool $public Files are public by default


/** @var \Doctrine\Common\Annotations\DocParser */
private $docParser;
private DocParser $docParser;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why (this is one of the examples of course) this cannot be constructor-promoted property? I feel like we should incorporate this rule more consistently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Given the amount of changes in scope, I assume we are not doing this - effectively a code style change - in this PR. The primary goal is to allow Symfony 6 to work, and everything else is optional.

If we have time to do so - great.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am ok with that, just wanted to highlight as I tried to move into that directions when I was tinkering with the code related to security layer.

src/lib/Resources/settings/settings.yml Show resolved Hide resolved
alongosz and others added 27 commits December 11, 2024 14:58
Co-Authored-By: Paweł Niedzielski <[email protected]>
Copy link

sonarcloud bot commented Dec 11, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Doc needed The changes require some documentation Feature New feature request Rebase required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants