Skip to content

Commit 6b03342

Browse files
committed
feature #1217 Upgrade to Symfony 5.3 (javiereguiluz, nicolas-grekas)
This PR was merged into the main branch. Discussion ---------- Upgrade to Symfony 5.3 For now, it's Symfony 5.3 RC1, but we'll keep updating this branch until 5.3 stable. ----- Things that I found while upgrading: ### Missing UPGRADE guide entry? In the UPGRADE guide (https://github.com/symfony/symfony/blob/5.3/UPGRADE-5.3.md) we don't even mention `enable_csrf`, but this change is needed in `config/packages/security.yaml`: Replace this: ```yaml form_login: csrf_token_generator: security.csrf.token_manager ``` by this: ```yaml form_login: enable_csrf: true ``` ----- ### Unexpected failures The upgrade guide mentions this: ``` PropertyInfo: Deprecated the Type::getCollectionKeyType() and Type::getCollectionValueType() methods, use Type::getCollectionKeyTypes() and Type::getCollectionValueTypes() instead ``` But we have these test failures: ``` App\Tests\Controller\Admin\BlogControllerTest::testAdminNewPost Error: Call to undefined method Symfony\Component\PropertyInfo\Type::getCollectionValueTypes() demo/vendor/symfony/validator/Mapping/Loader/PropertyInfoLoader.php:122 demo/vendor/symfony/validator/Mapping/Loader/LoaderChain.php:54 demo/vendor/symfony/validator/Mapping/Factory/LazyLoadingMetadataFactory.php:101 demo/vendor/symfony/validator/Validator/RecursiveValidator.php:76 demo/vendor/symfony/validator/Validator/TraceableValidator.php:50 demo/vendor/symfony/form/Extension/Validator/ValidatorTypeGuesser.php:265 demo/vendor/symfony/form/Extension/Validator/ValidatorTypeGuesser.php:38 demo/vendor/symfony/form/FormTypeGuesserChain.php:47 demo/vendor/symfony/form/FormTypeGuesserChain.php:93 demo/vendor/symfony/form/FormTypeGuesserChain.php:48 demo/vendor/symfony/form/FormFactory.php:84 demo/vendor/symfony/form/FormBuilder.php:97 demo/vendor/symfony/form/FormBuilder.php:244 demo/vendor/symfony/form/FormBuilder.php:195 demo/vendor/symfony/form/FormFactory.php:28 demo/vendor/symfony/framework-bundle/Controller/AbstractController.php:359 demo/src/Controller/Admin/BlogController.php:78 demo/vendor/symfony/http-kernel/HttpKernel.php:157 demo/vendor/symfony/http-kernel/HttpKernel.php:79 demo/vendor/symfony/http-kernel/Kernel.php:196 demo/vendor/symfony/http-kernel/HttpKernelBrowser.php:63 demo/vendor/symfony/framework-bundle/KernelBrowser.php:159 demo/vendor/symfony/browser-kit/AbstractBrowser.php:402 demo/tests/Controller/Admin/BlogControllerTest.php:89 ``` ----- ### Unexpected direct deprecations I see the following "direct deprecation" notices, but I don't know how they can be "direct deprecations". We don't use any of these in our code: ``` Remaining direct deprecation notices (7) 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder" class is deprecated, use "Symfony\Component\PasswordHasher\Hasher\SodiumPasswordHasher" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface" class is deprecated, use "Symfony\Component\PasswordHasher\PasswordHasherInterface" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\SelfSaltingEncoderInterface" interface is deprecated, use "Symfony\Component\PasswordHasher\LegacyPasswordHasherInterface" on hasher implementations that deal with salts instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder" class is deprecated, use "Symfony\Component\PasswordHasher\Hasher\Pbkdf2PasswordHasher" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\BasePasswordEncoder" class is deprecated, use "Symfony\Component\PasswordHasher\Hasher\CheckPasswordLengthTrait" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder" class is deprecated, use "Symfony\Component\PasswordHasher\Hasher\MessageDigestPasswordHasher" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\MigratingPasswordEncoder" class is deprecated, use "Symfony\Component\PasswordHasher\Hasher\MigratingPasswordHasher" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command ``` ----- ### Indirect deprecations to fix? There are still these "indirect deprecations". Are we missing some dependency updates ... or are these really deprecations pending to be fixed? ``` Remaining indirect deprecation notices (24) 19x: Since symfony/security-core 5.3: Not implementing method "loadUserByIdentifier()" in user provider "Symfony\Bridge\Doctrine\Security\User\EntityUserProvider" is deprecated. This method will replace "loadUserByUsername()" in Symfony 6.0. 4x in BlogControllerTest::testAccessDeniedForRegularUsers from App\Tests\Controller\Admin 4x in BlogControllerTest::testNewComment from App\Tests\Controller 2x in BlogControllerTest::testAdminDeletePost from App\Tests\Controller\Admin 2x in UserControllerTest::testEditUser from App\Tests\Controller 2x in UserControllerTest::testChangePassword from App\Tests\Controller 1x in BlogControllerTest::testAdminBackendHomePage from App\Tests\Controller\Admin 1x in BlogControllerTest::testAdminNewPost from App\Tests\Controller\Admin 1x in BlogControllerTest::testAdminNewDuplicatedPost from App\Tests\Controller\Admin 1x in BlogControllerTest::testAdminShowPost from App\Tests\Controller\Admin 1x in BlogControllerTest::testAdminEditPost from App\Tests\Controller\Admin 4x: Since symfony/http-foundation 5.3: "Symfony\Component\HttpFoundation\RequestStack::getMasterRequest()" is deprecated, use "getMainRequest()" instead. 4x in BlogControllerTest::testAccessDeniedForRegularUsers from App\Tests\Controller\Admin 1x: The "DAMA\DoctrineTestBundle\Doctrine\DBAL\AbstractStaticDriverV2" class implements "Doctrine\DBAL\Driver\ExceptionConverterDriver" that is deprecated. 1x in PHPUnitExtension::executeBeforeFirstTest from DAMA\DoctrineTestBundle\PHPUnit Other deprecation notices (18) 7x: Since symfony/security-bundle 5.3: The "security.password_encoder" service is deprecated, use "security.user_password_hasher" instead. 2x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 2x in AddUserCommandTest::testCreateUserInteractive from App\Tests\Command 2x in UserControllerTest::testChangePassword from App\Tests\Controller 1x in UserControllerTest::testAccessDeniedForAnonymousUsers from App\Tests\Controller 7x: Since symfony/security-bundle 5.3: The "security.encoder_factory.generic" service is deprecated, use "security.password_hasher_factory" instead. 2x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 2x in AddUserCommandTest::testCreateUserInteractive from App\Tests\Command 2x in UserControllerTest::testChangePassword from App\Tests\Controller 1x in UserControllerTest::testAccessDeniedForAnonymousUsers from App\Tests\Controller 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\UserPasswordEncoder" class is deprecated, use "Symfony\Component\PasswordHasher\Hasher\UserPasswordHasher" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface" interface is deprecated, use "Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\EncoderFactory" class is deprecated, use "Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command 1x: Since symfony/security-core 5.3: The "Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface" class is deprecated, use "Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface" instead. 1x in AddUserCommandTest::testCreateUserNonInteractive from App\Tests\Command ``` Commits ------- 2a9c975 Serializable is banned 58822bd composer up b0f5db5 Update assets/ cfeb771 Update code for 5.3 a410db9 Better constraints b6d91b2 Removed most deprecations 997ce81 Updated to Symfony 5.3 RC1
2 parents 4b8f9fa + 2a9c975 commit 6b03342

File tree

105 files changed

+2893
-2882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2893
-2882
lines changed

.env

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ APP_SECRET=2ca64f8d83b9e89f5f19d672841d6bb8
2222

2323
###> doctrine/doctrine-bundle ###
2424
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
25-
# For a MySQL database, use: "mysql://db_user:[email protected]:3306/db_name"
26-
# For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8"
2725
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
26+
#
2827
DATABASE_URL=sqlite:///%kernel.project_dir%/data/database.sqlite
28+
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7",
29+
# DATABASE_URL="postgresql://db_user:[email protected]:5432/db_name?serverVersion=13&charset=utf8"
2930
###< doctrine/doctrine-bundle ###
3031

3132
###> symfony/mailer ###

.env.test

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ KERNEL_CLASS='App\Kernel'
33
APP_SECRET='$ecretf0rt3st'
44
SYMFONY_DEPRECATIONS_HELPER=999999
55
PANTHER_APP_ENV=panther
6+
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
67
DATABASE_URL=sqlite:///%kernel.project_dir%/data/database_test.sqlite

.github/workflows/lint.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454

5555
- name: "Composer install"
5656
id: install
57-
run: composer install --no-interaction --no-progress --no-scripts
57+
run: composer install --no-interaction --no-progress
5858

5959
- name: Lint YAML files
6060
if: always() && steps.install.outcome == 'success'

assets/js/admin.js renamed to assets/admin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '../scss/admin.scss';
1+
import './styles/admin.scss';
22
import 'eonasdan-bootstrap-datetimepicker';
33
import 'typeahead.js';
44
import Bloodhound from "bloodhound-js";
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '../scss/app.scss';
1+
import './styles/app.scss';
22

33
// loads the Bootstrap jQuery plugins
44
import 'bootstrap-sass/assets/javascripts/bootstrap/transition.js';
@@ -9,7 +9,10 @@ import 'bootstrap-sass/assets/javascripts/bootstrap/modal.js';
99
import 'jquery'
1010

1111
// loads the code syntax highlighting library
12-
import './highlight.js';
12+
import './js/highlight.js';
1313

1414
// Creates links to the Symfony documentation
15-
import './doclinks.js';
15+
import './js/doclinks.js';
16+
17+
// start the Stimulus application
18+
import './bootstrap';

assets/bootstrap.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { startStimulusApp } from '@symfony/stimulus-bridge';
2+
3+
// Registers Stimulus controllers from controllers.json and in the controllers/ directory
4+
export const app = startStimulusApp(require.context(
5+
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
6+
true,
7+
/\.(j|t)sx?$/
8+
));
9+
10+
// register any custom, 3rd party controllers here
11+
// app.register('some_controller_name', SomeImportedController);

assets/controllers.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"controllers": [],
3+
"entrypoints": []
4+
}

assets/controllers/.gitignore

Whitespace-only changes.
File renamed without changes.

assets/js/search.js renamed to assets/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './jquery.instantSearch.js';
1+
import './js/jquery.instantSearch.js';
22

33
$(function() {
44
$('.search-field')
File renamed without changes.
File renamed without changes.

bin/console

+7-33
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,15 @@
33

44
use App\Kernel;
55
use Symfony\Bundle\FrameworkBundle\Console\Application;
6-
use Symfony\Component\Console\Input\ArgvInput;
7-
use Symfony\Component\Dotenv\Dotenv;
8-
use Symfony\Component\ErrorHandler\Debug;
96

10-
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
11-
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
7+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
8+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
129
}
1310

14-
set_time_limit(0);
11+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
1512

16-
require dirname(__DIR__).'/vendor/autoload.php';
13+
return function (array $context) {
14+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
1715

18-
if (!class_exists(Application::class) || !class_exists(Dotenv::class)) {
19-
throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.');
20-
}
21-
22-
$input = new ArgvInput();
23-
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
24-
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
25-
}
26-
27-
if ($input->hasParameterOption('--no-debug', true)) {
28-
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
29-
}
30-
31-
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
32-
33-
if ($_SERVER['APP_DEBUG']) {
34-
umask(0000);
35-
36-
if (class_exists(Debug::class)) {
37-
Debug::enable();
38-
}
39-
}
40-
41-
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
42-
$application = new Application($kernel);
43-
$application->run($input);
16+
return new Application($kernel);
17+
};

bin/phpunit

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#!/usr/bin/env php
22
<?php
3+
if (file_exists(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
4+
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
5+
} else {
6+
if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
7+
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
8+
exit(1);
9+
}
310

4-
if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
5-
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
6-
exit(1);
7-
}
11+
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
12+
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
13+
}
814

9-
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
10-
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
15+
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
1116
}
12-
13-
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';

composer.json

+22-20
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"license": "MIT",
44
"type": "project",
55
"description": "Symfony Demo Application",
6-
"minimum-stability": "stable",
6+
"minimum-stability": "dev",
77
"prefer-stable": true,
88
"replace": {
99
"symfony/polyfill-php72": "*",
@@ -19,38 +19,39 @@
1919
"erusev/parsedown": "^1.6",
2020
"sensio/framework-extra-bundle": "^6.1",
2121
"symfony/apache-pack": "^1.0",
22-
"symfony/asset": "^5.2",
23-
"symfony/console": "^5.2",
24-
"symfony/dotenv": "^5.2",
25-
"symfony/expression-language": "^5.2",
22+
"symfony/asset": "^5.3",
23+
"symfony/console": "^5.3",
24+
"symfony/dotenv": "^5.3",
25+
"symfony/expression-language": "^5.3",
2626
"symfony/flex": "^1.1",
27-
"symfony/form": "^5.2",
28-
"symfony/framework-bundle": "^5.2",
29-
"symfony/intl": "^5.2",
30-
"symfony/mailer": "^5.2",
27+
"symfony/form": "^5.3",
28+
"symfony/framework-bundle": "^5.3",
29+
"symfony/intl": "^5.3",
30+
"symfony/mailer": "^5.3",
3131
"symfony/monolog-bundle": "^3.1",
3232
"symfony/polyfill-intl-messageformatter": "^1.12",
33-
"symfony/security-bundle": "^5.2",
34-
"symfony/string": "^5.2",
35-
"symfony/translation": "^5.2",
33+
"symfony/security-bundle": "^5.3",
34+
"symfony/runtime": "^5.3",
35+
"symfony/string": "^5.3",
36+
"symfony/translation": "^5.3",
3637
"symfony/twig-pack": "^1.0",
37-
"symfony/validator": "^5.2",
38+
"symfony/validator": "^5.3",
3839
"symfony/webpack-encore-bundle": "^1.4",
39-
"symfony/yaml": "^5.2",
40+
"symfony/yaml": "^5.3",
4041
"tgalopin/html-sanitizer-bundle": "^1.2",
4142
"twig/intl-extra": "^3.0",
4243
"twig/markdown-extra": "^3.0"
4344
},
4445
"require-dev": {
4546
"dama/doctrine-test-bundle": "^6.2",
4647
"doctrine/doctrine-fixtures-bundle": "^3.0",
47-
"symfony/browser-kit": "^5.2",
48-
"symfony/css-selector": "^5.2",
49-
"symfony/debug-bundle": "^5.2",
48+
"symfony/browser-kit": "^5.3",
49+
"symfony/css-selector": "^5.3",
50+
"symfony/debug-bundle": "^5.3",
5051
"symfony/maker-bundle": "^1.11",
51-
"symfony/phpunit-bridge": "^5.2",
52-
"symfony/stopwatch": "^5.2",
53-
"symfony/web-profiler-bundle": "^5.2"
52+
"symfony/phpunit-bridge": "^5.3",
53+
"symfony/stopwatch": "^5.3",
54+
"symfony/web-profiler-bundle": "^5.3"
5455
},
5556
"config": {
5657
"platform": {
@@ -88,6 +89,7 @@
8889
},
8990
"extra": {
9091
"symfony": {
92+
"require": "5.3.*",
9193
"allow-contrib": true
9294
}
9395
}

0 commit comments

Comments
 (0)