Skip to content

Commit b382970

Browse files
Update to Laravel 9
1 parent dd49847 commit b382970

18 files changed

+1517
-1497
lines changed

app/Console/Commands/UpdatePublicSuffixList.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
use GuzzleHttp\Client;
66
use Illuminate\Console\Command;
7-
use Pdp\Converter;
8-
use Storage;
7+
use Illuminate\Support\Facades\Storage;
98

109
class UpdatePublicSuffixList extends Command
1110
{
@@ -17,9 +16,8 @@ public function handle()
1716
$client = new Client();
1817
$response = $client->get('https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat');
1918
$content = $response->getBody()->getContents();
20-
$rules = (new Converter())->convert($content);
2119

22-
Storage::put('public_suffix_list_converted', serialize($rules));
20+
Storage::put('public_suffix_list', $content);
2321

2422
$this->info('Public Suffix List cache updated.');
2523
}

app/Http/Kernel.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class Kernel extends HttpKernel
1111
*
1212
* These middleware are run during every request to your application.
1313
*
14-
* @var array
14+
* @var array<int, class-string|string>
1515
*/
1616
protected $middleware = [
1717
// \App\Http\Middleware\TrustHosts::class,
1818
\App\Http\Middleware\TrustProxies::class,
1919
\Fruitcake\Cors\HandleCors::class,
20-
\App\Http\Middleware\CheckForMaintenanceMode::class,
20+
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
2121
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
2222
\App\Http\Middleware\TrimStrings::class,
2323
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
@@ -26,7 +26,7 @@ class Kernel extends HttpKernel
2626
/**
2727
* The application's route middleware groups.
2828
*
29-
* @var array
29+
* @var array<string, array<int, class-string|string>>
3030
*/
3131
protected $middlewareGroups = [
3232
'web' => [
@@ -50,7 +50,7 @@ class Kernel extends HttpKernel
5050
*
5151
* These middleware may be assigned to groups or used individually.
5252
*
53-
* @var array
53+
* @var array<string, class-string|string>
5454
*/
5555
protected $routeMiddleware = [
5656
'auth' => \App\Http\Middleware\Authenticate::class,

app/Http/Middleware/Authenticate.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ class Authenticate extends Middleware
99
/**
1010
* Get the path the user should be redirected to when they are not authenticated.
1111
*
12-
* @param \Illuminate\Http\Request $request
12+
* @param \Illuminate\Http\Request $request
1313
* @return string|null
1414
*/
1515
protected function redirectTo($request)
1616
{
17-
if (! $request->expectsJson()) {
17+
if (!$request->expectsJson()) {
1818
return route('login');
1919
}
20-
21-
return null;
2220
}
2321
}

app/Http/Middleware/EncryptCookies.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class EncryptCookies extends Middleware
99
/**
1010
* The names of the cookies that should not be encrypted.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
1515
//

app/Http/Middleware/CheckForMaintenanceMode.php app/Http/Middleware/PreventRequestsDuringMaintenance.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace App\Http\Middleware;
44

5-
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
5+
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
66

7-
class CheckForMaintenanceMode extends Middleware
7+
class PreventRequestsDuringMaintenance extends Middleware
88
{
99
/**
1010
* The URIs that should be reachable while maintenance mode is enabled.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
1515
//

app/Http/Middleware/RedirectIfAuthenticated.php

+12-7
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,27 @@
44

55
use App\Providers\RouteServiceProvider;
66
use Closure;
7+
use Illuminate\Http\Request;
78
use Illuminate\Support\Facades\Auth;
89

910
class RedirectIfAuthenticated
1011
{
1112
/**
1213
* Handle an incoming request.
1314
*
14-
* @param \Illuminate\Http\Request $request
15-
* @param \Closure $next
16-
* @param string|null $guard
17-
* @return mixed
15+
* @param \Illuminate\Http\Request $request
16+
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
17+
* @param string|null ...$guards
18+
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
1819
*/
19-
public function handle($request, Closure $next, $guard = null)
20+
public function handle(Request $request, Closure $next, ...$guards)
2021
{
21-
if (Auth::guard($guard)->check()) {
22-
return redirect(RouteServiceProvider::HOME);
22+
$guards = empty($guards) ? [null] : $guards;
23+
24+
foreach ($guards as $guard) {
25+
if (Auth::guard($guard)->check()) {
26+
return redirect(RouteServiceProvider::HOME);
27+
}
2328
}
2429

2530
return $next($request);

app/Http/Middleware/TrimStrings.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ class TrimStrings extends Middleware
99
/**
1010
* The names of the attributes that should not be trimmed.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
15+
'current_password',
1516
'password',
1617
'password_confirmation',
1718
];

app/Http/Middleware/TrustHosts.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TrustHosts extends Middleware
99
/**
1010
* Get the host patterns that should be trusted.
1111
*
12-
* @return array
12+
* @return array<int, string|null>
1313
*/
1414
public function hosts()
1515
{

app/Http/Middleware/TrustProxies.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace App\Http\Middleware;
44

5-
use Fideloper\Proxy\TrustProxies as Middleware;
5+
use Illuminate\Http\Middleware\TrustProxies as Middleware;
66
use Illuminate\Http\Request;
77

88
class TrustProxies extends Middleware
99
{
1010
/**
1111
* The trusted proxies for this application.
1212
*
13-
* @var array|string|null
13+
* @var array<int, string>|string|null
1414
*/
1515
protected $proxies;
1616

@@ -19,5 +19,10 @@ class TrustProxies extends Middleware
1919
*
2020
* @var int
2121
*/
22-
protected $headers = Request::HEADER_X_FORWARDED_ALL;
22+
protected $headers =
23+
Request::HEADER_X_FORWARDED_FOR |
24+
Request::HEADER_X_FORWARDED_HOST |
25+
Request::HEADER_X_FORWARDED_PORT |
26+
Request::HEADER_X_FORWARDED_PROTO |
27+
Request::HEADER_X_FORWARDED_AWS_ELB;
2328
}

app/Http/Middleware/VerifyCsrfToken.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class VerifyCsrfToken extends Middleware
99
/**
1010
* The URIs that should be excluded from CSRF verification.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
1515
//

app/Jobs/ScanAlternateUrlsAndHeaders.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function isApex(string $baseAddress): bool
2020

2121
$domain = $rules->resolve(Arr::get($parsedUrl, 'host'));
2222

23-
return is_null($domain->getSubDomain());
23+
return $domain->subDomain()->count() === 0;
2424
}
2525

2626
protected function handleTask()

app/Providers/AppServiceProvider.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use App\GeoIPDatabase;
66
use App\ScannerClient;
7+
use Illuminate\Support\Facades\Storage;
78
use Illuminate\Support\ServiceProvider;
89
use Pdp\Rules;
9-
use Storage;
1010

1111
class AppServiceProvider extends ServiceProvider
1212
{
@@ -40,10 +40,14 @@ public function register()
4040
]);
4141
});
4242

43-
$this->app->bind(Rules::class, function () {
44-
$rules = Storage::get('public_suffix_list_converted');
43+
$this->app->singleton(Rules::class, function () {
44+
$content = Storage::get('public_suffix_list');
4545

46-
return new Rules(unserialize($rules));
46+
if (empty($content)) {
47+
throw new \Exception('Public Suffix List cache not available');
48+
}
49+
50+
return Rules::fromString($content);
4751
});
4852

4953
$this->app->singleton(GeoIPDatabase::class);

app/Website.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getIsApexAttribute(): bool
8888

8989
$domain = $rules->resolve(Arr::get($parsedUrl, 'host'));
9090

91-
return is_null($domain->getSubDomain());
91+
return $domain->subDomain()->count() === 0;
9292
}
9393

9494
public function updateIsFlarumStatus(bool $isFlarumNow)

composer.json

+13-14
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,36 @@
88
],
99
"license": "MIT",
1010
"require": {
11-
"php": "^7.4|^8.0",
11+
"php": "^8.0.2",
1212
"ext-curl": "*",
1313
"ext-fileinfo": "*",
1414
"ext-json": "*",
1515
"ext-zip": "*",
1616
"ext-zlib": "*",
17-
"composer/semver": "^3.0",
18-
"fideloper/proxy": "^4.2",
17+
"composer/semver": "^3.3",
1918
"fruitcake/laravel-cors": "^2.0",
20-
"guzzlehttp/guzzle": "^7.0.1",
21-
"jeremykendall/php-domain-parser": "^5.7",
22-
"laravel/framework": "^8.0",
19+
"guzzlehttp/guzzle": "^7.4.3",
20+
"jeremykendall/php-domain-parser": "^6.1",
21+
"laravel/framework": "^9.0",
2322
"laravel/horizon": "^5.0",
24-
"laravel/tinker": "^2.5",
23+
"laravel/tinker": "^2.7",
2524
"maxmind-db/reader": "^1.11",
2625
"predis/predis": "^1.1",
27-
"pusher/pusher-php-server": "^4.1",
26+
"pusher/pusher-php-server": "^7.0",
2827
"sentry/sentry-laravel": "^2.11",
2928
"spatie/browsershot": "^3.37",
3029
"spatie/laravel-csp": "^2.6",
31-
"spatie/laravel-medialibrary": "^9.0",
30+
"spatie/laravel-medialibrary": "^10.0",
3231
"symfony/css-selector": "^5.1",
3332
"symfony/dom-crawler": "^5.1"
3433
},
3534
"require-dev": {
3635
"barryvdh/laravel-debugbar": "^3.3",
37-
"facade/ignition": "^2.5",
38-
"fzaninotto/faker": "^1.9.1",
36+
"fakerphp/faker": "^1.9.1",
3937
"mockery/mockery": "^1.4.4",
40-
"nunomaduro/collision": "^5.0",
41-
"phpunit/phpunit": "^9.0"
38+
"nunomaduro/collision": "^6.1",
39+
"phpunit/phpunit": "^9.5.10",
40+
"spatie/laravel-ignition": "^1.0"
4241
},
4342
"autoload": {
4443
"psr-4": {
@@ -77,7 +76,7 @@
7776
"preferred-install": "dist",
7877
"sort-packages": true,
7978
"platform": {
80-
"php": "7.4"
79+
"php": "8.0.2"
8180
}
8281
},
8382
"minimum-stability": "dev",

0 commit comments

Comments
 (0)