From 6f712816c0987f2f66b720bf1af5b24856d3504b Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Tue, 2 Apr 2024 00:30:05 +0800 Subject: [PATCH] Fix Symfony deprecations (#753) Bug: T357844 --- config/packages/framework.yaml | 2 +- config/packages/test/framework.yaml | 2 +- config/services.yaml | 2 +- src/Kernel.php | 10 +++++----- src/Service/MediaWikiApi.php | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 42273ddb..c8a0b499 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -8,7 +8,7 @@ framework: # Write session files to the var/ directory # and make sure they're limited to the tool's own path on Toolforge. session: - storage_id: Wikimedia\ToolforgeBundle\Service\NativeSessionStorage + storage_factory_id: session.storage.factory.native save_path: "%kernel.project_dir%/var/sessions/%kernel.environment%" # esi: true diff --git a/config/packages/test/framework.yaml b/config/packages/test/framework.yaml index d153e0d2..54824eef 100644 --- a/config/packages/test/framework.yaml +++ b/config/packages/test/framework.yaml @@ -1,4 +1,4 @@ framework: test: true session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file diff --git a/config/services.yaml b/config/services.yaml index a04394b6..47ebc288 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -32,7 +32,7 @@ services: arguments: $entryPoint: "%wiki_url%" $client: '@MediaWiki\OAuthClient\Client' - $session: "@session" + $requestStack: "@request_stack" App\Service\FileCache: arguments: diff --git a/src/Kernel.php b/src/Kernel.php index 1cc61367..506b51c5 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -12,7 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; class Kernel extends BaseKernel { @@ -60,13 +60,13 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); } - protected function configureRoutes(RouteCollectionBuilder $routes): void + protected function configureRoutes(RoutingConfigurator $routes): void { $confDir = $this->getProjectDir().'/config'; - $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS); + $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS); + $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS); } public function boot():void diff --git a/src/Service/MediaWikiApi.php b/src/Service/MediaWikiApi.php index e10e51df..ea83d1b2 100644 --- a/src/Service/MediaWikiApi.php +++ b/src/Service/MediaWikiApi.php @@ -11,7 +11,7 @@ use MediaWiki\OAuthClient\Client as OauthClient; use MediaWiki\OAuthClient\Token; use stdClass; -use Symfony\Component\HttpFoundation\Session\Session; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Exception\HttpException; /** @@ -33,11 +33,11 @@ class MediaWikiApi /** * @param string $entryPoint Fully-qualified URL of the wiki's api.php */ - public function __construct(string $entryPoint, OauthClient $client, Session $session) + public function __construct(string $entryPoint, OauthClient $client, RequestStack $requestStack) { $this->entryPoint = $entryPoint; $this->oauthClient = $client; - $this->oauthAccessToken = $session->get('oauth.access_token'); + $this->oauthAccessToken = $requestStack->getSession()->get('oauth.access_token'); } /**