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

Upgrade to Symfony 6.1 #1339

Merged
merged 1 commit into from
Jun 21, 2022
Merged

Upgrade to Symfony 6.1 #1339

merged 1 commit into from
Jun 21, 2022

Conversation

javiereguiluz
Copy link
Member

Don't mind much about the sanitize_html Twig filter. I added it quickly to make the application work. We're discussing about how adding again this Twig filter in the Symfony HtmlSanitizer component.


These are the remaining deprecations:

Remaining indirect deprecation notices (6)

  1x: The "DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver" class implements "Doctrine\DBAL\VersionAwarePlatformDriver" that is deprecated All drivers will have to be aware of the server version in the next major release.
    1x in PHPUnitExtension::executeBeforeFirstTest from DAMA\DoctrineTestBundle\PHPUnit

  1x: The "Symfony\Bridge\Doctrine\Logger\DbalLogger" class implements "Doctrine\DBAL\Logging\SQLLogger" that is deprecated Use {@see \Doctrine\DBAL\Logging\Middleware} or implement {@see \Doctrine\DBAL\Driver\Middleware} instead.
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

  1x: Method "ArrayAccess::offsetExists()" might add "bool" as a native return type declaration in the future. Do the same in implementation "Dflydev\DotAccessData\Data" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in BlogControllerTest::testAdminShowPost from App\Tests\Controller\Admin

  1x: Method "ArrayAccess::offsetGet()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Dflydev\DotAccessData\Data" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in BlogControllerTest::testAdminShowPost from App\Tests\Controller\Admin

  1x: Method "ArrayAccess::offsetSet()" might add "void" as a native return type declaration in the future. Do the same in implementation "Dflydev\DotAccessData\Data" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in BlogControllerTest::testAdminShowPost from App\Tests\Controller\Admin

  1x: Method "ArrayAccess::offsetUnset()" might add "void" as a native return type declaration in the future. Do the same in implementation "Dflydev\DotAccessData\Data" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in BlogControllerTest::testAdminShowPost from App\Tests\Controller\Admin

@dmaicher do you know how can we remove the deprecation notice about DoctrineTestBundle? Thanks!

@derrabus do you know how can we fix the deprecation about Symfony\Bridge\Doctrine\Logger\DbalLogger? Thanks!

@stof
Copy link
Member

stof commented May 12, 2022

For the DbalLogger, the work is in progress at doctrine/DoctrineBundle#1517


public function sanitize(string $unsafeHtmlContents): string
{
$htmlSanitizer = new HtmlSanitizer((new HtmlSanitizerConfig())->allowSafeElements());
Copy link
Member

Choose a reason for hiding this comment

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

you should rather showcase using the service configured by FrameworkBundle (by injecting the HtmlSanitizerInterface)

Copy link
Member Author

@javiereguiluz javiereguiluz May 12, 2022

Choose a reason for hiding this comment

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

Yes ... but HtmlSanitizer component will probably add the Twig extension again ... so we'll remove ours. Let's wait a bit before doing any change. Thanks!

@dmaicher
Copy link
Contributor

@javiereguiluz regarding

  1x: The "DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver" class implements "Doctrine\DBAL\VersionAwarePlatformDriver" that is deprecated All drivers will have to be aware of the server version in the next major release.
    1x in PHPUnitExtension::executeBeforeFirstTest from DAMA\DoctrineTestBundle\PHPUnit

unfortunately there is no way to fix this deprecation 😕 Also see dmaicher/doctrine-test-bundle#188 (comment)

@javiereguiluz
Copy link
Member Author

@dmaicher thanks a lot for your reply. However, I'm afraid I don't understand this well:

unfortunately there is no way to fix this deprecation

You mean that this can't be fixed in DoctrineTestBundle and need to be fixed somewhere else (e.g. Doctrine DBAL) or you really mean that it cannot be fixed in any way. Thanks!

@dmaicher
Copy link
Contributor

There is no way currently to get rid of this deprecation because of DBAL. The VersionAwarePlatformDriver interface is deprecated but still needs to be implemented. There is no forward compatibility layer on DBAL so that it works without implementing the interface.

So I don't see any way of fixing this unless maybe there is a forward compatibility path on DBAL itself that would allow not implementing the interface.

@javiereguiluz
Copy link
Member Author

@dmaicher I see. Thanks for explaining this in detail. Maybe @stof knows people in the Doctrine organization or, specifically, the DBAL project that could take a look about this. Thanks!

@javiereguiluz
Copy link
Member Author

I've deleted the custom sanitize_html Twig filter to use the filter with the same name provided by HtmlSanitizer component (it was added here: symfony/symfony#46335)

But, I'm seeing this error:

error-2

Any clue? Thanks!

nicolas-grekas added a commit to symfony/symfony that referenced this pull request May 29, 2022
…er services (nicolas-grekas)

This PR was merged into the 6.1 branch.

Discussion
----------

[FrameworkBundle][TwigBundle] Fix registering html-sanitizer services

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | symfony/demo#1339 (comment)
| License       | MIT
| Doc PR        | -

Commits
-------

9876f2f [FrameworkBundle][TwigBundle] Fix registering html-sanitizer services
},
"require": {
"php": ">=8.0.2",
"php": ">=8.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

do not forget the readme file's requirements :)

@javiereguiluz
Copy link
Member Author

javiereguiluz commented Jun 21, 2022

Can anybody please help me? I can't make the HTML sanitizer work. Instead of sanitizing, it just removes everything. I'm reading https://symfony.com/doc/current/html_sanitizer.html but I can't find the cause of the bug. Thanks!

Fixed! The html_sanitizer.yaml config file wasn't being processed by Symfony on my local machine for unknown reasons. I deleted the cache and then it worked.

@@ -9,10 +9,11 @@
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*"
"symfony/polyfill-php80": "*",
Copy link
Contributor

Choose a reason for hiding this comment

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

both can be removed as now the php version is forced via the require

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'm not sure ... all these are in the replace section of composer.json. If I'm right, listing them here means that Composer won't download those packages even if some dependency requires them. So, the idea is that you add new polyfills when you upgrade your minimum required PHP version.

Copy link
Contributor

Choose a reason for hiding this comment

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

ho right! I did not pay attention where the location were at first :s my bad

Copy link
Member

Choose a reason for hiding this comment

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

this is indeed the list of polyfills that are replaced by the project platform requirements. So they should be added, not removed.

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.

4 participants