From 1b78f0ca60db8545a6ebc03ff8049ff9b3e0d4e5 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 24 Jul 2020 17:27:59 +0200 Subject: [PATCH 1/5] Replace a few forgotten obsolete helpers - Apparently, I forgot that `array_flatten` comes from Laravel. :) - When I did this previously, I did not search the views directory. --- framework/core/src/Extension/Extension.php | 2 +- framework/core/src/Foundation/Site.php | 3 ++- framework/core/src/Frontend/Content/Assets.php | 3 ++- framework/core/views/frontend/admin.blade.php | 6 +++--- framework/core/views/frontend/forum.blade.php | 12 ++++++------ 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/framework/core/src/Extension/Extension.php b/framework/core/src/Extension/Extension.php index 6ae5947f6..3707bfae0 100644 --- a/framework/core/src/Extension/Extension.php +++ b/framework/core/src/Extension/Extension.php @@ -267,7 +267,7 @@ class Extension implements Arrayable $extenders = [$extenders]; } - return array_flatten($extenders); + return Arr::flatten($extenders); } /** diff --git a/framework/core/src/Foundation/Site.php b/framework/core/src/Foundation/Site.php index 13b715b2c..54dfcb7e1 100644 --- a/framework/core/src/Foundation/Site.php +++ b/framework/core/src/Foundation/Site.php @@ -9,6 +9,7 @@ namespace Flarum\Foundation; +use Illuminate\Support\Arr; use RuntimeException; class Site @@ -62,6 +63,6 @@ class Site return []; } - return array_flatten($extenders); + return Arr::flatten($extenders); } } diff --git a/framework/core/src/Frontend/Content/Assets.php b/framework/core/src/Frontend/Content/Assets.php index e160adb34..50681f876 100644 --- a/framework/core/src/Frontend/Content/Assets.php +++ b/framework/core/src/Frontend/Content/Assets.php @@ -13,6 +13,7 @@ use Flarum\Foundation\Application; use Flarum\Frontend\Compiler\CompilerInterface; use Flarum\Frontend\Document; use Illuminate\Contracts\Container\Container; +use Illuminate\Support\Arr; use Psr\Http\Message\ServerRequestInterface as Request; class Assets @@ -48,7 +49,7 @@ class Assets ]; if ($this->app->inDebugMode()) { - $this->commit(array_flatten($compilers)); + $this->commit(Arr::flatten($compilers)); } $document->js = array_merge($document->js, $this->getUrls($compilers['js'])); diff --git a/framework/core/views/frontend/admin.blade.php b/framework/core/views/frontend/admin.blade.php index 2efce2af5..abab7d7fb 100644 --- a/framework/core/views/frontend/admin.blade.php +++ b/framework/core/views/frontend/admin.blade.php @@ -8,9 +8,9 @@

- - - @if ($logo = array_get($forum, 'logoUrl')) + + + @if ($logo = \Illuminate\Support\Arr::get($forum, 'logoUrl')) @else {{ $title }} diff --git a/framework/core/views/frontend/forum.blade.php b/framework/core/views/frontend/forum.blade.php index 01c0c7261..d4dd5cd9f 100644 --- a/framework/core/views/frontend/forum.blade.php +++ b/framework/core/views/frontend/forum.blade.php @@ -1,4 +1,4 @@ -{!! array_get($forum, 'headerHtml') !!} +{!! \Illuminate\Support\Arr::get($forum, 'headerHtml') !!}
@@ -10,11 +10,11 @@
-{!! array_get($forum, 'footerHtml') !!} +{!! \Illuminate\Support\Arr::get($forum, 'footerHtml') !!} From 8a7e70550e335463b197c424e1639fa7817670f3 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 24 Jul 2020 17:31:46 +0200 Subject: [PATCH 2/5] Inject Symfony translator contract, not Laravel's The Laravel changes with v6, and our translator is primarily an implementation of the Symfony contract. --- framework/core/src/Forum/Content/Index.php | 11 ++++++++--- framework/core/src/User/AccountActivationMailer.php | 8 ++++---- .../src/User/Command/RequestPasswordResetHandler.php | 8 ++++---- framework/core/src/User/EmailConfirmationMailer.php | 6 +++--- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/framework/core/src/Forum/Content/Index.php b/framework/core/src/Forum/Content/Index.php index 1593ac147..2f0d506e0 100644 --- a/framework/core/src/Forum/Content/Index.php +++ b/framework/core/src/Forum/Content/Index.php @@ -15,10 +15,10 @@ use Flarum\Frontend\Document; use Flarum\Http\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\User; -use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\View\Factory; use Illuminate\Support\Arr; use Psr\Http\Message\ServerRequestInterface as Request; +use Symfony\Component\Translation\TranslatorInterface; class Index { @@ -42,14 +42,19 @@ class Index */ protected $url; + /** + * @var TranslatorInterface + */ + protected $translator; + /** * @param Client $api * @param Factory $view * @param SettingsRepositoryInterface $settings * @param UrlGenerator $url - * @param Translator $translator + * @param TranslatorInterface $translator */ - public function __construct(Client $api, Factory $view, SettingsRepositoryInterface $settings, UrlGenerator $url, Translator $translator) + public function __construct(Client $api, Factory $view, SettingsRepositoryInterface $settings, UrlGenerator $url, TranslatorInterface $translator) { $this->api = $api; $this->view = $view; diff --git a/framework/core/src/User/AccountActivationMailer.php b/framework/core/src/User/AccountActivationMailer.php index a07f3e6de..883b170d6 100644 --- a/framework/core/src/User/AccountActivationMailer.php +++ b/framework/core/src/User/AccountActivationMailer.php @@ -14,7 +14,7 @@ use Flarum\Mail\Job\SendRawEmailJob; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\Event\Registered; use Illuminate\Contracts\Queue\Queue; -use Illuminate\Contracts\Translation\Translator; +use Symfony\Component\Translation\TranslatorInterface; class AccountActivationMailer { @@ -34,7 +34,7 @@ class AccountActivationMailer protected $url; /** - * @var Translator + * @var TranslatorInterface */ protected $translator; @@ -42,9 +42,9 @@ class AccountActivationMailer * @param \Flarum\Settings\SettingsRepositoryInterface $settings * @param Queue $queue * @param UrlGenerator $url - * @param Translator $translator + * @param TranslatorInterface $translator */ - public function __construct(SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, Translator $translator) + public function __construct(SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, TranslatorInterface $translator) { $this->settings = $settings; $this->queue = $queue; diff --git a/framework/core/src/User/Command/RequestPasswordResetHandler.php b/framework/core/src/User/Command/RequestPasswordResetHandler.php index b18e927cc..9dc7d726a 100644 --- a/framework/core/src/User/Command/RequestPasswordResetHandler.php +++ b/framework/core/src/User/Command/RequestPasswordResetHandler.php @@ -15,10 +15,10 @@ use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\PasswordToken; use Flarum\User\UserRepository; use Illuminate\Contracts\Queue\Queue; -use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\Validation\Factory; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Validation\ValidationException; +use Symfony\Component\Translation\TranslatorInterface; class RequestPasswordResetHandler { @@ -43,7 +43,7 @@ class RequestPasswordResetHandler protected $url; /** - * @var Translator + * @var TranslatorInterface */ protected $translator; @@ -57,7 +57,7 @@ class RequestPasswordResetHandler * @param SettingsRepositoryInterface $settings * @param Queue $queue * @param UrlGenerator $url - * @param Translator $translator + * @param TranslatorInterface $translator * @param Factory $validatorFactory */ public function __construct( @@ -65,7 +65,7 @@ class RequestPasswordResetHandler SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, - Translator $translator, + TranslatorInterface $translator, Factory $validatorFactory ) { $this->users = $users; diff --git a/framework/core/src/User/EmailConfirmationMailer.php b/framework/core/src/User/EmailConfirmationMailer.php index 5d35b95ed..1a052f974 100644 --- a/framework/core/src/User/EmailConfirmationMailer.php +++ b/framework/core/src/User/EmailConfirmationMailer.php @@ -14,7 +14,7 @@ use Flarum\Mail\Job\SendRawEmailJob; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\Event\EmailChangeRequested; use Illuminate\Contracts\Queue\Queue; -use Illuminate\Contracts\Translation\Translator; +use Symfony\Component\Translation\TranslatorInterface; class EmailConfirmationMailer { @@ -34,11 +34,11 @@ class EmailConfirmationMailer protected $url; /** - * @var Translator + * @var TranslatorInterface */ protected $translator; - public function __construct(SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, Translator $translator) + public function __construct(SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, TranslatorInterface $translator) { $this->settings = $settings; $this->queue = $queue; From bf774d8a9bc7e4d6e46c5b7b3438f4a5175366c7 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 24 Jul 2020 17:32:50 +0200 Subject: [PATCH 3/5] Make Translator compatible with Laravel 6 It's contract will change in Laravel 6. We extend from Symfony's translator, but need to be compatible with that from Laravel in order to use its validation package. References: - https://laravel.com/docs/6.x/upgrade#trans-and-trans-choice - https://github.com/laravel/framework/commit/8557dc56b11c5e4dc746cb5558d6e694131f0dd8#diff-88bc04a1548d09aa6250d902d1ac2b4c --- framework/core/src/Locale/Translator.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/framework/core/src/Locale/Translator.php b/framework/core/src/Locale/Translator.php index 90bce7e06..369924b8a 100644 --- a/framework/core/src/Locale/Translator.php +++ b/framework/core/src/Locale/Translator.php @@ -17,6 +17,16 @@ class Translator extends BaseTranslator implements TranslatorContract { const REFERENCE_REGEX = '/^=>\s*([a-z0-9_\-\.]+)$/i'; + public function get($key, array $replace = [], $locale = null) + { + return $this->trans($key, $replace, null, $locale); + } + + public function choice($key, $number, array $replace = [], $locale = null) + { + return $this->transChoice($key, $number, $replace, nil, $locale); + } + /** * {@inheritdoc} */ From aeffe31cc1ebc98a402c76111c9c99421a2d9d7e Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 24 Jul 2020 17:34:40 +0200 Subject: [PATCH 4/5] Update to Laravel 6, finally! Fixes #2055. --- framework/core/composer.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/framework/core/composer.json b/framework/core/composer.json index 3ea49ccd3..2732f8dc9 100644 --- a/framework/core/composer.json +++ b/framework/core/composer.json @@ -41,21 +41,21 @@ "dflydev/fig-cookies": "^2.0.1", "doctrine/dbal": "^2.7", "franzl/whoops-middleware": "^0.4.0", - "illuminate/bus": "5.8.*", - "illuminate/cache": "5.8.*", - "illuminate/config": "5.8.*", - "illuminate/container": "5.8.*", - "illuminate/contracts": "5.8.*", - "illuminate/database": "5.8.*", - "illuminate/events": "5.8.*", - "illuminate/filesystem": "5.8.*", - "illuminate/hashing": "5.8.*", - "illuminate/mail": "5.8.*", - "illuminate/queue": "5.8.*", - "illuminate/session": "5.8.*", - "illuminate/support": "5.8.*", - "illuminate/validation": "5.8.*", - "illuminate/view": "5.8.*", + "illuminate/bus": "^6.0", + "illuminate/cache": "^6.0", + "illuminate/config": "^6.0", + "illuminate/container": "^6.0", + "illuminate/contracts": "^6.0", + "illuminate/database": "^6.0", + "illuminate/events": "^6.0", + "illuminate/filesystem": "^6.0", + "illuminate/hashing": "^6.0", + "illuminate/mail": "^6.0", + "illuminate/queue": "^6.0", + "illuminate/session": "^6.0", + "illuminate/support": "^6.0", + "illuminate/validation": "^6.0", + "illuminate/view": "^6.0", "intervention/image": "^2.5.0", "laminas/laminas-diactoros": "^1.8.4", "laminas/laminas-httphandlerrunner": "^1.0", From c6ed69b5499947eb4f0e7562dfd58ae5e6a2cca1 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 24 Jul 2020 22:56:31 +0200 Subject: [PATCH 5/5] Simplify a few unnecessary Arr::get() calls --- framework/core/views/frontend/admin.blade.php | 9 ++++----- framework/core/views/frontend/forum.blade.php | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/framework/core/views/frontend/admin.blade.php b/framework/core/views/frontend/admin.blade.php index abab7d7fb..38e29fb81 100644 --- a/framework/core/views/frontend/admin.blade.php +++ b/framework/core/views/frontend/admin.blade.php @@ -8,12 +8,11 @@

- - - @if ($logo = \Illuminate\Support\Arr::get($forum, 'logoUrl')) - + + @if ($forum['logoUrl']) + @else - {{ $title }} + {{ $forum['title'] }} @endif

diff --git a/framework/core/views/frontend/forum.blade.php b/framework/core/views/frontend/forum.blade.php index d4dd5cd9f..c6de4f301 100644 --- a/framework/core/views/frontend/forum.blade.php +++ b/framework/core/views/frontend/forum.blade.php @@ -1,4 +1,4 @@ -{!! \Illuminate\Support\Arr::get($forum, 'headerHtml') !!} +{!! $forum['headerHtml'] !!}
@@ -10,11 +10,11 @@
-{!! \Illuminate\Support\Arr::get($forum, 'footerHtml') !!} +{!! $forum['footerHtml'] !!}