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

Update to Symfony 6.4 #1431

Merged
merged 1 commit into from
Nov 22, 2023
Merged

Update to Symfony 6.4 #1431

merged 1 commit into from
Nov 22, 2023

Conversation

javiereguiluz
Copy link
Member

@javiereguiluz javiereguiluz commented Oct 9, 2023

After upgrade, I can't see any direct deprecation in our code.

These are the indirect deprecations:

Remaining indirect deprecation notices (47)

  44x: Subscribing to postConnect events is deprecated. Implement a middleware instead.
  (Connection.php:387 called by Connection.php:452, https://github.com/doctrine/dbal/issues/5784, package doctrine/dbal)
    10x in BlogControllerTest::setUp from App\Tests\Controller\Admin
    5x in DefaultControllerTest::tearDown from App\Tests\Controller
    4x in BlogControllerTest::testNewComment from App\Tests\Controller
    2x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command
    2x in AddUserCommandTest::testCreateUserInteractive from App\Tests\Command
    ...

  1x: Since symfony/monolog-bridge 6.4: The "Symfony\Bridge\Monolog\Logger" class is deprecated,
  use HttpKernel's DebugLoggerConfigurator instead.
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

  1x: The "Monolog\Logger" class is considered final. It may change without further notice
  as of its next major version. You should not extend it from "Symfony\Bridge\Monolog\Logger".
    1x in AddUserCommandTest::testCreateUserNonInteractive with data set #0 from App\Tests\Command

  1x: Subscribing to postConnect events is deprecated. Implement a middleware instead.
  (Connection.php:387 called by Connection.php:1654, https://github.com/doctrine/dbal/issues/5784, package doctrine/dbal)
    1x in UserControllerTest::testEditUser from App\Tests\Controller

Other deprecation notices (44)

  44x: In ORM 3.0, the AttributeDriver will report fields for the classes where they are declared.
  This may uncover invalid mapping configurations. To opt into the new mode today, set the
  "reportFieldsWhereDeclared" constructor parameter to true.
  (AttributeDriver.php:78 called by App_KernelTestDebugContainer.php:816, https://github.com/doctrine/orm/pull/10455, package doctrine/orm)
    10x in BlogControllerTest::setUp from App\Tests\Controller\Admin
    5x in DefaultControllerTest::tearDown from App\Tests\Controller
    4x in BlogControllerTest::testNewComment from App\Tests\Controller
    2x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command
    2x in AddUserCommandTest::testCreateUserInteractive from App\Tests\Command
    ...

@javiereguiluz
Copy link
Member Author

After updating dependencies again, now we see some errors like this one:

1) App\Tests\Controller\Admin\BlogControllerTest::testAccessDeniedForRegularUsers with data set #0 ('GET', '/en/admin/post/')
Error: Call to undefined method Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer::getFileLink()

/home/runner/work/demo/demo/vendor/symfony/error-handler/Resources/views/trace.html.php:14
/home/runner/work/demo/demo/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:337
/home/runner/work/demo/demo/vendor/symfony/error-handler/Resources/views/traces.html.php:52
/home/runner/work/demo/demo/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:337
/home/runner/work/demo/demo/vendor/symfony/error-handler/Resources/views/exception.html.php:57
/home/runner/work/demo/demo/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:337
/home/runner/work/demo/demo/vendor/symfony/error-handler/Resources/views/exception_full.html.php:35
/home/runner/work/demo/demo/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:[33](https://github.com/symfony/demo/actions/runs/6543565287/job/17768359222?pr=1431#step:10:34)7
/home/runner/work/demo/demo/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:144
/home/runner/work/demo/demo/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:70
/home/runner/work/demo/demo/vendor/symfony/twig-bridge/ErrorRenderer/TwigErrorRenderer.php:48
/home/runner/work/demo/demo/vendor/symfony/error-handler/ErrorRenderer/SerializerErrorRenderer.php:65
/home/runner/work/demo/demo/vendor/symfony/http-kernel/Controller/ErrorController.php:41
/home/runner/work/demo/demo/vendor/symfony/http-kernel/HttpKernel.php:181
/home/runner/work/demo/demo/vendor/symfony/http-kernel/HttpKernel.php:76
/home/runner/work/demo/demo/vendor/symfony/http-kernel/EventListener/ErrorListener.php:117
/home/runner/work/demo/demo/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:116
/home/runner/work/demo/demo/vendor/symfony/event-dispatcher/EventDispatcher.php:220
/home/runner/work/demo/demo/vendor/symfony/event-dispatcher/EventDispatcher.php:56
/home/runner/work/demo/demo/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:139
/home/runner/work/demo/demo/vendor/symfony/http-kernel/HttpKernel.php:239
/home/runner/work/demo/demo/vendor/symfony/http-kernel/HttpKernel.php:91
/home/runner/work/demo/demo/vendor/symfony/http-kernel/Kernel.php:197
/home/runner/work/demo/demo/vendor/symfony/http-kernel/HttpKernelBrowser.php:65
/home/runner/work/demo/demo/vendor/symfony/framework-bundle/KernelBrowser.php:175
/home/runner/work/demo/demo/vendor/symfony/browser-kit/AbstractBrowser.php:[38](https://github.com/symfony/demo/actions/runs/6543565287/job/17768359222?pr=1431#step:10:39)5
/home/runner/work/demo/demo/tests/Controller/Admin/BlogControllerTest.php:65

@wouterj
Copy link
Member

wouterj commented Oct 17, 2023

See symfony/symfony#52088

@stof
Copy link
Member

stof commented Oct 17, 2023

For the reportFieldsWhereDeclared deprecation of the ORM, DoctrineBundle 2.10.0 added a report_fields_where_declared configuration setting to control it.

Edit: updating the DoctrineBundle recipe to its latest version would enable this setting, as recipes are turning it on for new projects.

@stof
Copy link
Member

stof commented Oct 17, 2023

The postConnect deprecation comes from dama/doctrine-test-bundle. They have beta releases of their 8.0 version where this is fixed.

@javiereguiluz
Copy link
Member Author

Thank you for the info about how to solve some of the deprecations! Great team effort!


After last updates, I see these indirect deprecations:

Remaining indirect deprecation notices (4)

  1x: Since symfony/monolog-bridge 6.4: The "Symfony\Bridge\Monolog\Logger" class is deprecated, use HttpKernel's DebugLoggerConfigurator instead.
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

  1x: The "Monolog\Logger" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Bridge\Monolog\Logger".
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

  1x: Since symfony/dependency-injection 6.4: "Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader" is deprecated, use dependency injection in your fixtures instead.
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

  1x: The "Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader" class extends "Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader" that is deprecated since Symfony 6.4, use dependency injection in your fixtures instead.
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

Other deprecation notices (44)

  44x: In ORM 3.0, the AttributeDriver will report fields for the classes where they are declared. This may uncover invalid mapping configurations. To opt into the new mode today, set the "reportFieldsWhereDeclared" constructor parameter to true. (AttributeDriver.php:78 called by App_KernelTestDebugContainer.php:819, https://github.com/doctrine/orm/pull/10455, package doctrine/orm)
    10x in BlogControllerTest::setUp from App\Tests\Controller\Admin
    5x in DefaultControllerTest::tearDown from App\Tests\Controller
    4x in BlogControllerTest::testNewComment from App\Tests\Controller
    2x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command
    2x in AddUserCommandTest::testCreateUserInteractive from App\Tests\Command
    ...

@javiereguiluz
Copy link
Member Author

There are the remaining indirect deprecations after the last changes:

Remaining indirect deprecation notices (3)

  1x: The "Symfony\UX\LiveComponent\Twig\TemplateCacheWarmer::warmUp()" method will require a new "string|null $buildDir" argument in the next major version of its interface "Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface", not defining it is deprecated.
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

  1x: Since symfony/monolog-bridge 6.4: The "Symfony\Bridge\Monolog\Logger" class is deprecated, use HttpKernel's DebugLoggerConfigurator instead.
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

  1x: The "Monolog\Logger" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Bridge\Monolog\Logger".
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

@javiereguiluz
Copy link
Member Author

Here are the indirect deprecations after the last updates:

  1x: The "Symfony\UX\LiveComponent\Twig\TemplateCacheWarmer::warmUp()" method will require a new "string|null $buildDir" argument in the next major version of its interface "Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface", not defining it is deprecated.
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

  1x: Since symfony/monolog-bridge 6.4: The "Symfony\Bridge\Monolog\Logger" class is deprecated, use HttpKernel's DebugLoggerConfigurator instead.
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

  1x: The "Monolog\Logger" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Bridge\Monolog\Logger".
    1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command

@seb-jean
Copy link
Contributor

seb-jean commented Nov 2, 2023

Should we keep the logout function? Because there is the Simpler Logout now.
https://github.com/symfony/demo/blob/main/src/Controller/SecurityController.php#L70

@javiereguiluz
Copy link
Member Author

After upgrading to Symfony 6.4.0-RC1, there's only 1 indirect deprecation:

17x: Since symfony/http-kernel 6.4:
Callable "Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction()"
is not allowed as a controller.

Did you miss tagging it with "#[AsController]" or registering its type with 
"Symfony\Component\HttpKernel\Controller\ControllerResolver::allowControllers()"?

We use that templateAction controller in:

demo/config/routes.yaml

Lines 5 to 12 in 206f0c9

homepage:
path: /{_locale}
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction
requirements:
_locale: '%app_locales%'
defaults:
template: default/homepage.html.twig
_locale: '%locale%'

@javiereguiluz
Copy link
Member Author

There's also a PHPStan issue. Which would be the best fix in this case?

  Line   src/Pagination/Paginator.php
 ------ ----------------------------------------------------------------------------------------------------------------------------
  70     Property App\Pagination\Paginator::$results (Traversable<int, object>) does not accept ArrayIterator<(int|string), mixed>.

@stof
Copy link
Member

stof commented Nov 16, 2023

Allowing TemplateController as a controller is something that should be fixed in FrameworkBundle.

for the phpstan error, it is a mismatch between the type of your Paginator and the ORM one used inside it (the part about values can be solved, but the part about keys cannot without changing types of Paginator as the ORM paginator says that the keys in its iterator are always array-key, i.e. int|string)

@javiereguiluz
Copy link
Member Author

I don't know how to solve the PHPStan error. I'm trying with this:

    /**
     * @var \Traversable<int|string, object>|\ArrayIterator<(int|string), mixed>
     */
    private \Traversable|\ArrayIterator $results;

But the error persists. I need help here. Thanks!

@javiereguiluz
Copy link
Member Author

The PHPStan issue was finally fixed thanks to the smart folks of Symfony Slack such as @mbbaker and @dkarlovi. Thanks!

@stof
Copy link
Member

stof commented Nov 21, 2023

The remaining indirect deprecation has been fixed in symfony/symfony#52656

@javiereguiluz
Copy link
Member Author

javiereguiluz commented Nov 22, 2023

I'm merging this "as is" ... so we can work in parallel ... preparing the PR with the upgrade to the final 6.4 version ... and also the PR to upgrade it to 7.0.

The plan is to tag a version of this demo with 6.4 stable and soon after, tag another version with 7.0 stable.

@javiereguiluz javiereguiluz merged commit 38ad58e into symfony:main Nov 22, 2023
@javiereguiluz javiereguiluz deleted the sf64 branch November 22, 2023 17:07
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.

5 participants