From 33267f073676656677d54a7f5c2181919cd7ef84 Mon Sep 17 00:00:00 2001
From: Jeremy Benoist <jeremy.benoist@gmail.com>
Date: Tue, 13 Dec 2022 13:39:24 +0100
Subject: [PATCH] Update to FOSUserBundle 3.1

Also remove some deprecation from Symfony.
Use `LegacyEventDispatcherProxy` to handle Symfony 4 dispatch from FOSUser
---
 .github/dependabot.yml                        |  5 --
 app/config/config.yml                         |  6 +-
 app/config/security.yml                       |  2 -
 composer.json                                 |  2 +-
 composer.lock                                 | 76 +++++++++++--------
 phpstan-baseline.neon                         | 25 +++---
 .../DependencyInjection/Configuration.php     |  5 +-
 .../Controller/UserRestController.php         |  3 +-
 .../DependencyInjection/Configuration.php     |  5 +-
 .../CoreBundle/Command/InstallCommand.php     |  3 +-
 .../DependencyInjection/Configuration.php     |  4 +-
 .../SQLiteCascadeDeleteSubscriber.php         |  4 +-
 .../CoreBundle/Helper/ContentProxy.php        |  8 +-
 .../CoreBundle/Helper/DownloadImages.php      |  8 +-
 .../UsernameFeedTokenConverter.php            |  2 +-
 .../DependencyInjection/Configuration.php     |  4 +-
 .../Controller/ManageController.php           |  3 +-
 .../DependencyInjection/Configuration.php     |  5 +-
 src/Wallabag/UserBundle/Entity/User.php       |  6 --
 .../Settings/modify.html.twig                 |  0
 .../changePassword_content.html.twig          |  0
 .../Registration/check_email.html.twig        |  0
 .../Registration/confirmed.html.twig          |  0
 .../Registration/register_content.html.twig   |  0
 .../Resetting/check_email.html.twig           |  0
 .../Resetting/request_content.html.twig       |  0
 .../Resetting/reset_content.html.twig         |  0
 .../FOSUserBundle}/Security/login.html.twig   |  0
 .../bundles/FOSUserBundle}/layout.html.twig   |  0
 .../UsernameFeedTokenConverterTest.php        |  6 +-
 30 files changed, 90 insertions(+), 92 deletions(-)
 rename {app/Resources/CraueConfigBundle/views => templates/bundles/CraueConfigBundle}/Settings/modify.html.twig (100%)
 rename {app/Resources/FOSUserBundle/views => templates/bundles/FOSUserBundle}/ChangePassword/changePassword_content.html.twig (100%)
 rename {app/Resources/FOSUserBundle/views => templates/bundles/FOSUserBundle}/Registration/check_email.html.twig (100%)
 rename {app/Resources/FOSUserBundle/views => templates/bundles/FOSUserBundle}/Registration/confirmed.html.twig (100%)
 rename {app/Resources/FOSUserBundle/views => templates/bundles/FOSUserBundle}/Registration/register_content.html.twig (100%)
 rename {app/Resources/FOSUserBundle/views => templates/bundles/FOSUserBundle}/Resetting/check_email.html.twig (100%)
 rename {app/Resources/FOSUserBundle/views => templates/bundles/FOSUserBundle}/Resetting/request_content.html.twig (100%)
 rename {app/Resources/FOSUserBundle/views => templates/bundles/FOSUserBundle}/Resetting/reset_content.html.twig (100%)
 rename {app/Resources/FOSUserBundle/views => templates/bundles/FOSUserBundle}/Security/login.html.twig (100%)
 rename {app/Resources/FOSUserBundle/views => templates/bundles/FOSUserBundle}/layout.html.twig (100%)

diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 4c4a44dc2..7e41eda4c 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -22,15 +22,10 @@ updates:
   - j0k3r
   - tcitworld
   - Kdecherf
-  labels:
-  - Ready for review
   ignore:
   - dependency-name: doctrine/doctrine-migrations-bundle
     versions:
     - "> 1.3.2"
-  - dependency-name: friendsofsymfony/user-bundle
-    versions:
-    - "> 2.0.2"
 - package-ecosystem: github-actions
   directory: "/"
   schedule:
diff --git a/app/config/config.yml b/app/config/config.yml
index 011039853..bf821691b 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -179,8 +179,10 @@ fos_user:
         confirmation:
             enabled: "%fosuser_confirmation%"
     from_email:
-        address:        "%from_email%"
-        sender_name:    wallabag
+        address: "%from_email%"
+        sender_name: wallabag
+    service:
+        mailer: fos_user.mailer.twig_swift
 
 fos_oauth_server:
     db_driver:           orm
diff --git a/app/config/security.yml b/app/config/security.yml
index 2a09648f3..9ab516215 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -34,12 +34,10 @@ security:
             provider: fos_userbundle
 
         login_firewall:
-            logout_on_user_change: true
             pattern: ^/login$
             anonymous:  ~
 
         secured_area:
-            logout_on_user_change: true
             pattern: ^/
             form_login:
                 provider: fos_userbundle
diff --git a/composer.json b/composer.json
index 631b6f62c..09da6d396 100644
--- a/composer.json
+++ b/composer.json
@@ -69,7 +69,7 @@
         "friendsofsymfony/jsrouting-bundle": "^2.2",
         "friendsofsymfony/oauth-server-bundle": "^1.5",
         "friendsofsymfony/rest-bundle": "~2.1",
-        "friendsofsymfony/user-bundle": "2.1.*",
+        "friendsofsymfony/user-bundle": "^3.1",
         "guzzlehttp/guzzle": "^5.3.1",
         "guzzlehttp/psr7": "^1.8",
         "html2text/html2text": "^4.1",
diff --git a/composer.lock b/composer.lock
index cccbe48ea..1d03018f6 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "56b46a7637ad10cb3e659d390f684c01",
+    "content-hash": "baee037be9102a34e52539f8bafb370d",
     "packages": [
         {
             "name": "babdev/pagerfanta-bundle",
@@ -2621,46 +2621,56 @@
         },
         {
             "name": "friendsofsymfony/user-bundle",
-            "version": "v2.1.2",
+            "version": "v3.1.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git",
-                "reference": "1049935edd24ec305cc6cfde1875372fa9600446"
+                "reference": "89c18b6944adb12541f5b3b1ab39287b5336b375"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/1049935edd24ec305cc6cfde1875372fa9600446",
-                "reference": "1049935edd24ec305cc6cfde1875372fa9600446",
+                "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/89c18b6944adb12541f5b3b1ab39287b5336b375",
+                "reference": "89c18b6944adb12541f5b3b1ab39287b5336b375",
                 "shasum": ""
             },
             "require": {
-                "paragonie/random_compat": "^1 || ^2",
-                "php": "^5.5.9 || ^7.0",
-                "symfony/form": "^2.8 || ^3.0 || ^4.0",
-                "symfony/framework-bundle": "^2.8 || ^3.0 || ^4.0",
-                "symfony/security-bundle": "^2.8 || ^3.0 || ^4.0",
-                "symfony/templating": "^2.8 || ^3.0 || ^4.0",
-                "symfony/twig-bundle": "^2.8 || ^3.0 || ^4.0",
-                "symfony/validator": "^2.8 || ^3.0 || ^4.0",
-                "twig/twig": "^1.28 || ^2.0"
+                "ext-dom": "*",
+                "ext-json": "*",
+                "php": "^7.4 || ^8.0",
+                "symfony/config": "^4.4 || ^5.0 || ^6.0",
+                "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
+                "symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0",
+                "symfony/event-dispatcher-contracts": "^1.1 || ^2.0 || ^3.0",
+                "symfony/form": "^4.4 || ^5.0 || ^6.0",
+                "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",
+                "symfony/http-foundation": "^4.4 || ^5.0 || ^6.0",
+                "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0",
+                "symfony/options-resolver": "^4.4 || ^5.0 || ^6.0",
+                "symfony/routing": "^4.4 || ^5.0 || ^6.0",
+                "symfony/security-bundle": "^4.4 || ^5.0 || ^6.0",
+                "symfony/security-core": "^4.4 || ^5.0 || ^6.0",
+                "symfony/translation": "^4.4 || ^5.0 || ^6.0",
+                "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0",
+                "symfony/validator": "^4.4 || ^5.0 || ^6.0",
+                "twig/twig": "^1.34 || ^2.4 || ^3.0"
             },
             "conflict": {
                 "doctrine/doctrine-bundle": "<1.3",
-                "symfony/doctrine-bridge": "<2.7"
+                "doctrine/persistence": "<1.3",
+                "symfony/doctrine-bridge": "<4.4"
             },
             "require-dev": {
-                "doctrine/doctrine-bundle": "^1.3",
-                "friendsofphp/php-cs-fixer": "^2.2",
-                "phpunit/phpunit": "^4.8.35|^5.7.11|^6.5",
+                "doctrine/doctrine-bundle": "^1.3 || ^2",
+                "friendsofphp/php-cs-fixer": "^3.0.2, !=3.5.0",
                 "swiftmailer/swiftmailer": "^4.3 || ^5.0 || ^6.0",
-                "symfony/console": "^2.8 || ^3.0 || ^4.0",
-                "symfony/phpunit-bridge": "^2.8 || ^3.0 || ^4.0",
-                "symfony/yaml": "^2.8 || ^3.0 || ^4.0"
+                "symfony/console": "^4.4 || ^5.0 || ^6.0",
+                "symfony/phpunit-bridge": "^6.1",
+                "symfony/yaml": "^4.4 || ^5.0 || ^6.0"
             },
             "type": "symfony-bundle",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "2.1.x-dev"
+                    "dev-master": "3.x-dev"
                 }
             },
             "autoload": {
@@ -2681,11 +2691,11 @@
                     "email": "stof@notk.org"
                 },
                 {
-                    "name": "FriendsOfSymfony Community",
-                    "homepage": "https://github.com/friendsofsymfony/FOSUserBundle/contributors"
+                    "name": "Thibault Duplessis"
                 },
                 {
-                    "name": "Thibault Duplessis"
+                    "name": "FriendsOfSymfony Community",
+                    "homepage": "https://github.com/friendsofsymfony/FOSUserBundle/contributors"
                 }
             ],
             "description": "Symfony FOSUserBundle",
@@ -2696,9 +2706,9 @@
             "support": {
                 "docs": "https://symfony.com/doc/master/bundles/FOSUserBundle/index.html",
                 "issues": "https://github.com/FriendsOfSymfony/FOSUserBundle/issues",
-                "source": "https://github.com/FriendsOfSymfony/FOSUserBundle/tree/v2.1.2"
+                "source": "https://github.com/FriendsOfSymfony/FOSUserBundle/tree/v3.1.0"
             },
-            "time": "2018-03-08T08:59:27+00:00"
+            "time": "2022-10-26T09:10:52+00:00"
         },
         {
             "name": "gedmo/doctrine-extensions",
@@ -4577,16 +4587,16 @@
         },
         {
             "name": "j0k3r/graby-site-config",
-            "version": "1.0.159",
+            "version": "1.0.160",
             "source": {
                 "type": "git",
                 "url": "https://github.com/j0k3r/graby-site-config.git",
-                "reference": "e5bfb9d608f0ce6390d6791ede196c769216ee84"
+                "reference": "17994c315b292e3ff7bcbd0e982a2df849792a55"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/j0k3r/graby-site-config/zipball/e5bfb9d608f0ce6390d6791ede196c769216ee84",
-                "reference": "e5bfb9d608f0ce6390d6791ede196c769216ee84",
+                "url": "https://api.github.com/repos/j0k3r/graby-site-config/zipball/17994c315b292e3ff7bcbd0e982a2df849792a55",
+                "reference": "17994c315b292e3ff7bcbd0e982a2df849792a55",
                 "shasum": ""
             },
             "require": {
@@ -4615,9 +4625,9 @@
             "description": "Graby site config files",
             "support": {
                 "issues": "https://github.com/j0k3r/graby-site-config/issues",
-                "source": "https://github.com/j0k3r/graby-site-config/tree/1.0.159"
+                "source": "https://github.com/j0k3r/graby-site-config/tree/1.0.160"
             },
-            "time": "2022-11-01T02:53:54+00:00"
+            "time": "2022-12-01T02:33:16+00:00"
         },
         {
             "name": "j0k3r/httplug-ssrf-plugin",
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 10a4c15d4..78b2f0571 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -30,11 +30,6 @@ parameters:
             count: 1
             path: src/Wallabag/CoreBundle/Controller/StaticController.php
 
-        -
-            message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
-            count: 1
-            path: src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
-
         -
             message: "#^Call to an undefined method Lexik\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpressionBuilder\\(\\)\\.$#"
             count: 1
@@ -70,11 +65,6 @@ parameters:
             count: 1
             path: src/Wallabag/ImportBundle/Controller/WallabagController.php
 
-        -
-            message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
-            count: 1
-            path: src/Wallabag/ImportBundle/DependencyInjection/Configuration.php
-
         -
             message: "#^Call to an undefined method Scheb\\\\TwoFactorBundle\\\\Model\\\\Email\\\\TwoFactorInterface\\:\\:getName\\(\\)\\.$#"
             count: 2
@@ -94,3 +84,18 @@ parameters:
             message: "#^Property Tests\\\\Wallabag\\\\CoreBundle\\\\Helper\\\\RedirectTest\\:\\:\\$routerMock has unknown class PHPUnit_Framework_MockObject_MockObject as its type\\.$#"
             count: 1
             path: tests/Wallabag/CoreBundle/Helper/RedirectTest.php
+
+        -
+            message: "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch()#"
+            count: 1
+            path: src/Wallabag/ApiBundle/Controller/UserRestController.php
+
+        -
+            message: "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch()#"
+            count: 1
+            path: src/Wallabag/CoreBundle/Command/InstallCommand.php
+
+        -
+            message: "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch()#"
+            count: 1
+            path: src/Wallabag/UserBundle/Controller/ManageController.php
diff --git a/src/Wallabag/AnnotationBundle/DependencyInjection/Configuration.php b/src/Wallabag/AnnotationBundle/DependencyInjection/Configuration.php
index 5e4e4e9c7..b3b5f8226 100644
--- a/src/Wallabag/AnnotationBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/AnnotationBundle/DependencyInjection/Configuration.php
@@ -12,9 +12,6 @@ class Configuration implements ConfigurationInterface
      */
     public function getConfigTreeBuilder()
     {
-        $treeBuilder = new TreeBuilder();
-        $rootNode = $treeBuilder->root('wallabag_annotation');
-
-        return $treeBuilder;
+        return new TreeBuilder('wallabag_annotation');
     }
 }
diff --git a/src/Wallabag/ApiBundle/Controller/UserRestController.php b/src/Wallabag/ApiBundle/Controller/UserRestController.php
index 182e659e6..8d07c1297 100644
--- a/src/Wallabag/ApiBundle/Controller/UserRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/UserRestController.php
@@ -11,6 +11,7 @@ use JMS\Serializer\SerializerInterface;
 use Nelmio\ApiDocBundle\Annotation\Operation;
 use Swagger\Annotations as SWG;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
 use Symfony\Component\HttpFoundation\JsonResponse;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Annotation\Route;
@@ -159,7 +160,7 @@ class UserRestController extends WallabagRestController
 
         // dispatch a created event so the associated config will be created
         $event = new UserEvent($user, $request);
-        $this->get(EventDispatcherInterface::class)->dispatch(FOSUserEvents::USER_CREATED, $event);
+        LegacyEventDispatcherProxy::decorate($this->get(EventDispatcherInterface::class))->dispatch($event, FOSUserEvents::USER_CREATED);
 
         return $this->sendUser($user, 'user_api_with_client', JsonResponse::HTTP_CREATED);
     }
diff --git a/src/Wallabag/ApiBundle/DependencyInjection/Configuration.php b/src/Wallabag/ApiBundle/DependencyInjection/Configuration.php
index f70a58358..276374018 100644
--- a/src/Wallabag/ApiBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/ApiBundle/DependencyInjection/Configuration.php
@@ -17,9 +17,6 @@ class Configuration implements ConfigurationInterface
      */
     public function getConfigTreeBuilder()
     {
-        $treeBuilder = new TreeBuilder();
-        $rootNode = $treeBuilder->root('wallabag_api');
-
-        return $treeBuilder;
+        return new TreeBuilder('wallabag_api');
     }
 }
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index bc3e61d14..f0ca9f57a 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -18,6 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Question\Question;
 use Symfony\Component\Console\Style\SymfonyStyle;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
 use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
 use Wallabag\CoreBundle\Entity\InternalSetting;
 use Wallabag\UserBundle\Entity\User;
@@ -281,7 +282,7 @@ class InstallCommand extends ContainerAwareCommand
 
         // dispatch a created event so the associated config will be created
         $event = new UserEvent($user);
-        $this->getContainer()->get(EventDispatcherInterface::class)->dispatch(FOSUserEvents::USER_CREATED, $event);
+        LegacyEventDispatcherProxy::decorate($this->getContainer()->get(EventDispatcherInterface::class))->dispatch($event, FOSUserEvents::USER_CREATED);
 
         $this->io->text('<info>Administration successfully setup.</info>');
 
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
index 34d24b6bb..fa31ecda4 100644
--- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
@@ -9,8 +9,8 @@ class Configuration implements ConfigurationInterface
 {
     public function getConfigTreeBuilder()
     {
-        $treeBuilder = new TreeBuilder();
-        $rootNode = $treeBuilder->root('wallabag_core');
+        $treeBuilder = new TreeBuilder('wallabag_core');
+        $rootNode = $treeBuilder->getRootNode();
 
         $rootNode
             ->children()
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
index 7dd95994a..4b9d5c243 100644
--- a/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
+++ b/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
@@ -2,10 +2,10 @@
 
 namespace Wallabag\CoreBundle\Event\Subscriber;
 
-use Doctrine\Bundle\DoctrineBundle\Registry;
 use Doctrine\Common\EventSubscriber;
 use Doctrine\DBAL\Platforms\SqlitePlatform;
 use Doctrine\ORM\Event\LifecycleEventArgs;
+use Doctrine\Persistence\ManagerRegistry;
 use Wallabag\CoreBundle\Entity\Entry;
 
 /**
@@ -19,7 +19,7 @@ class SQLiteCascadeDeleteSubscriber implements EventSubscriber
 {
     private $doctrine;
 
-    public function __construct(Registry $doctrine)
+    public function __construct(ManagerRegistry $doctrine)
     {
         $this->doctrine = $doctrine;
     }
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index cb64b4b74..918f10c66 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -4,7 +4,7 @@ namespace Wallabag\CoreBundle\Helper;
 
 use Graby\Graby;
 use Psr\Log\LoggerInterface;
-use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
+use Symfony\Component\Mime\MimeTypes;
 use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
 use Symfony\Component\Validator\Constraints\Url as UrlConstraint;
 use Symfony\Component\Validator\Validator\ValidatorInterface;
@@ -22,7 +22,7 @@ class ContentProxy
     protected $ignoreOriginProcessor;
     protected $validator;
     protected $logger;
-    protected $mimeGuesser;
+    protected $mimeTypes;
     protected $fetchingErrorMessage;
     protected $eventDispatcher;
     protected $storeArticleHeaders;
@@ -34,7 +34,7 @@ class ContentProxy
         $this->ignoreOriginProcessor = $ignoreOriginProcessor;
         $this->validator = $validator;
         $this->logger = $logger;
-        $this->mimeGuesser = new MimeTypeExtensionGuesser();
+        $this->mimeTypes = new MimeTypes();
         $this->fetchingErrorMessage = $fetchingErrorMessage;
         $this->storeArticleHeaders = $storeArticleHeaders;
     }
@@ -296,7 +296,7 @@ class ContentProxy
         }
 
         // if content is an image, define it as a preview too
-        if (!empty($content['headers']['content-type']) && \in_array($this->mimeGuesser->guess($content['headers']['content-type']), ['jpeg', 'jpg', 'gif', 'png'], true)) {
+        if (!empty($content['headers']['content-type']) && \in_array(current($this->mimeTypes->getExtensions($content['headers']['content-type'])), ['jpeg', 'jpg', 'gif', 'png'], true)) {
             $previewPictureUrl = $content['url'];
         } elseif (empty($previewPictureUrl)) {
             $this->logger->debug('Extracting images from content to provide a default preview picture');
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
index 9aa549862..477b509ac 100644
--- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php
+++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
@@ -15,7 +15,7 @@ use Psr\Http\Message\ResponseInterface;
 use Psr\Log\LoggerInterface;
 use Symfony\Component\DomCrawler\Crawler;
 use Symfony\Component\Finder\Finder;
-use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
+use Symfony\Component\Mime\MimeTypes;
 
 class DownloadImages
 {
@@ -24,7 +24,7 @@ class DownloadImages
     private $client;
     private $baseFolder;
     private $logger;
-    private $mimeGuesser;
+    private $mimeTypes;
     private $wallabagUrl;
 
     public function __construct(HttpClient $client, $baseFolder, $wallabagUrl, LoggerInterface $logger, MessageFactory $messageFactory = null)
@@ -33,7 +33,7 @@ class DownloadImages
         $this->baseFolder = $baseFolder;
         $this->wallabagUrl = rtrim($wallabagUrl, '/');
         $this->logger = $logger;
-        $this->mimeGuesser = new MimeTypeExtensionGuesser();
+        $this->mimeTypes = new MimeTypes();
 
         $this->setFolder();
     }
@@ -355,7 +355,7 @@ class DownloadImages
      */
     private function getExtensionFromResponse(ResponseInterface $res, $imagePath)
     {
-        $ext = $this->mimeGuesser->guess(current($res->getHeader('content-type')));
+        $ext = current($this->mimeTypes->getExtensions(current($res->getHeader('content-type'))));
         $this->logger->debug('DownloadImages: Checking extension', ['ext' => $ext, 'header' => $res->getHeader('content-type')]);
 
         // ok header doesn't have the extension, try a different way
diff --git a/src/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverter.php b/src/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverter.php
index 28ca892ab..754d24680 100644
--- a/src/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverter.php
+++ b/src/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverter.php
@@ -2,7 +2,7 @@
 
 namespace Wallabag\CoreBundle\ParamConverter;
 
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
 use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
 use Symfony\Component\HttpFoundation\Request;
diff --git a/src/Wallabag/ImportBundle/DependencyInjection/Configuration.php b/src/Wallabag/ImportBundle/DependencyInjection/Configuration.php
index 39df9d3f9..3694c863e 100644
--- a/src/Wallabag/ImportBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/ImportBundle/DependencyInjection/Configuration.php
@@ -9,8 +9,8 @@ class Configuration implements ConfigurationInterface
 {
     public function getConfigTreeBuilder()
     {
-        $treeBuilder = new TreeBuilder();
-        $rootNode = $treeBuilder->root('wallabag_import');
+        $treeBuilder = new TreeBuilder('wallabag_import');
+        $rootNode = $treeBuilder->getRootNode();
 
         $rootNode
             ->children()
diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php
index 72922b4eb..2b01a9b68 100644
--- a/src/Wallabag/UserBundle/Controller/ManageController.php
+++ b/src/Wallabag/UserBundle/Controller/ManageController.php
@@ -11,6 +11,7 @@ use Pagerfanta\Pagerfanta;
 use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface;
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
 use Symfony\Component\Form\Form;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
@@ -49,7 +50,7 @@ class ManageController extends Controller
 
             // dispatch a created event so the associated config will be created
             $event = new UserEvent($user, $request);
-            $this->get(EventDispatcherInterface::class)->dispatch(FOSUserEvents::USER_CREATED, $event);
+            LegacyEventDispatcherProxy::decorate($this->get(EventDispatcherInterface::class))->dispatch($event, FOSUserEvents::USER_CREATED);
 
             $this->get(SessionInterface::class)->getFlashBag()->add(
                 'notice',
diff --git a/src/Wallabag/UserBundle/DependencyInjection/Configuration.php b/src/Wallabag/UserBundle/DependencyInjection/Configuration.php
index 4223f8dba..e5f785368 100644
--- a/src/Wallabag/UserBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/UserBundle/DependencyInjection/Configuration.php
@@ -9,9 +9,6 @@ class Configuration implements ConfigurationInterface
 {
     public function getConfigTreeBuilder()
     {
-        $treeBuilder = new TreeBuilder();
-        $rootNode = $treeBuilder->root('wallabag_user');
-
-        return $treeBuilder;
+        return new TreeBuilder('wallabag_user');
     }
 }
diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php
index 2c3cced45..4c7747797 100644
--- a/src/Wallabag/UserBundle/Entity/User.php
+++ b/src/Wallabag/UserBundle/Entity/User.php
@@ -12,7 +12,6 @@ use Scheb\TwoFactorBundle\Model\BackupCodeInterface;
 use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface as EmailTwoFactorInterface;
 use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface as GoogleTwoFactorInterface;
 use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
-use Symfony\Component\Security\Core\User\UserInterface;
 use Wallabag\ApiBundle\Entity\Client;
 use Wallabag\CoreBundle\Entity\Config;
 use Wallabag\CoreBundle\Entity\Entry;
@@ -205,11 +204,6 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
         return $this->entries;
     }
 
-    public function isEqualTo(UserInterface $user)
-    {
-        return $this->username === $user->getUsername();
-    }
-
     /**
      * Set config.
      *
diff --git a/app/Resources/CraueConfigBundle/views/Settings/modify.html.twig b/templates/bundles/CraueConfigBundle/Settings/modify.html.twig
similarity index 100%
rename from app/Resources/CraueConfigBundle/views/Settings/modify.html.twig
rename to templates/bundles/CraueConfigBundle/Settings/modify.html.twig
diff --git a/app/Resources/FOSUserBundle/views/ChangePassword/changePassword_content.html.twig b/templates/bundles/FOSUserBundle/ChangePassword/changePassword_content.html.twig
similarity index 100%
rename from app/Resources/FOSUserBundle/views/ChangePassword/changePassword_content.html.twig
rename to templates/bundles/FOSUserBundle/ChangePassword/changePassword_content.html.twig
diff --git a/app/Resources/FOSUserBundle/views/Registration/check_email.html.twig b/templates/bundles/FOSUserBundle/Registration/check_email.html.twig
similarity index 100%
rename from app/Resources/FOSUserBundle/views/Registration/check_email.html.twig
rename to templates/bundles/FOSUserBundle/Registration/check_email.html.twig
diff --git a/app/Resources/FOSUserBundle/views/Registration/confirmed.html.twig b/templates/bundles/FOSUserBundle/Registration/confirmed.html.twig
similarity index 100%
rename from app/Resources/FOSUserBundle/views/Registration/confirmed.html.twig
rename to templates/bundles/FOSUserBundle/Registration/confirmed.html.twig
diff --git a/app/Resources/FOSUserBundle/views/Registration/register_content.html.twig b/templates/bundles/FOSUserBundle/Registration/register_content.html.twig
similarity index 100%
rename from app/Resources/FOSUserBundle/views/Registration/register_content.html.twig
rename to templates/bundles/FOSUserBundle/Registration/register_content.html.twig
diff --git a/app/Resources/FOSUserBundle/views/Resetting/check_email.html.twig b/templates/bundles/FOSUserBundle/Resetting/check_email.html.twig
similarity index 100%
rename from app/Resources/FOSUserBundle/views/Resetting/check_email.html.twig
rename to templates/bundles/FOSUserBundle/Resetting/check_email.html.twig
diff --git a/app/Resources/FOSUserBundle/views/Resetting/request_content.html.twig b/templates/bundles/FOSUserBundle/Resetting/request_content.html.twig
similarity index 100%
rename from app/Resources/FOSUserBundle/views/Resetting/request_content.html.twig
rename to templates/bundles/FOSUserBundle/Resetting/request_content.html.twig
diff --git a/app/Resources/FOSUserBundle/views/Resetting/reset_content.html.twig b/templates/bundles/FOSUserBundle/Resetting/reset_content.html.twig
similarity index 100%
rename from app/Resources/FOSUserBundle/views/Resetting/reset_content.html.twig
rename to templates/bundles/FOSUserBundle/Resetting/reset_content.html.twig
diff --git a/app/Resources/FOSUserBundle/views/Security/login.html.twig b/templates/bundles/FOSUserBundle/Security/login.html.twig
similarity index 100%
rename from app/Resources/FOSUserBundle/views/Security/login.html.twig
rename to templates/bundles/FOSUserBundle/Security/login.html.twig
diff --git a/app/Resources/FOSUserBundle/views/layout.html.twig b/templates/bundles/FOSUserBundle/layout.html.twig
similarity index 100%
rename from app/Resources/FOSUserBundle/views/layout.html.twig
rename to templates/bundles/FOSUserBundle/layout.html.twig
diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php
index e8a82e49a..9c7a41731 100644
--- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php
+++ b/tests/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverterTest.php
@@ -2,9 +2,9 @@
 
 namespace Tests\Wallabag\CoreBundle\ParamConverter;
 
-use Doctrine\Common\Persistence\ManagerRegistry;
-use Doctrine\Common\Persistence\Mapping\ClassMetadata;
-use Doctrine\Common\Persistence\ObjectManager;
+use Doctrine\Persistence\ManagerRegistry;
+use Doctrine\Persistence\Mapping\ClassMetadata;
+use Doctrine\Persistence\ObjectManager;
 use PHPUnit\Framework\TestCase;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
 use Symfony\Component\HttpFoundation\Request;