Skip to content

Commit 00c5872

Browse files
authored
Laravel 10 Upgrade (#730)
* wip composer.json * WIP - departure to integrate https://github.com/googleapis/google-cloud-php-errorreporting * replace `gluedev/laravel-stackdriver` * configure `absszero/laravel-stackdriver-error-reporting` see #731 * remove call to `registerPolicies` see https://laravel.com/docs/10.x/upgrade#register-policies * schedule redis stale tag pruning * use `$casts` property see https://laravel.com/docs/10.x/upgrade#model-dates-property * run `composer update --ignore-platform-reqs` Composer version 2.6.5 2023-10-06 10:11:52 * rename `$routeMiddleware` see https://laravel.com/docs/10.x/upgrade#middleware-aliases * Apply curated changes from laravel/laravel@9.x...10.x * test: php 8.2 * update php version in composer * remove custom stackdriver repo * upgrade to phpunit 10 * migrate phpunit configuration * re-add "absszero/laravel-stackdriver-error-reporting" * replace CORS Handler * refactor data providers * refactor `$this->dispatch` & `dispatchNow` * fix test class name * refactor some tests * update phpunit to 10.5, run composer update * migrate ElasticSearchIndexDeleteTest.php * fix deprecated string interpolation * tests: replace job to queue dispatching with calling handle() * implement ForceSearchIndex::uniqueId * move to `dispatch` as mostly recommended example
1 parent e59eda7 commit 00c5872

Some content is hidden

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

49 files changed

+1038
-1281
lines changed

.github/workflows/composer.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install dependencies
2323
uses: php-actions/composer@v6
2424
with:
25-
php_version: 8.1
25+
php_version: 8.2
2626
command: install
2727

2828
- name: Copy example .env file

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Homestead.yaml
66
.env
77
.php_cs.cache
88
.phpunit.result.cache
9+
.phpunit.cache
910
/storage/*.key
1011
/public/storage
1112
_ide_helper.php

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# api
22

3+
## 10x.0.0 - 26 February 2024
4+
- Update Laravel to v10.10 - T341797
5+
- schedule redis stale tag pruning
6+
- refactor: `dispatchNow` was removed
7+
- Update to PHPUnit v10.5
8+
- fix: Implemented ForceSearchIndex::uniqueId T358106
9+
310
## 9x.1.0 - 16 Februrary 2024
411
- Switching to PHP 8.2
512

app/Console/Commands/Wiki/SetSetting.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function handle()
4141
'wiki_id' => $wiki->id,
4242
'name' => $settingKey,
4343
])->delete();
44-
$this->line("Deleted setting ${settingKey} for wiki id ${wikiId}");
44+
$this->line("Deleted setting {$settingKey} for wiki id {$wikiId}");
4545
return;
4646
}
4747

@@ -54,7 +54,7 @@ public function handle()
5454
'value' => $settingValue,
5555
]
5656
);
57-
$this->line("Set setting ${settingKey} to ${settingValue} for wiki id ${wikiId}");
57+
$this->line("Set setting {$settingKey} to {$settingValue} for wiki id {$wikiId}");
5858

5959
return 0;
6060
}

app/Console/Kernel.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ class Kernel extends ConsoleKernel
2222
* Define the application's command schedule.
2323
*
2424
* @param \Illuminate\Console\Scheduling\Schedule $schedule
25-
* @return void
2625
*/
27-
protected function schedule(Schedule $schedule)
26+
protected function schedule(Schedule $schedule): void
2827
{
2928
// Make sure that the DB and QS pools are always populated somewhat.
3029
// This will create at most 1 new entry for each per minute...
@@ -48,6 +47,9 @@ protected function schedule(Schedule $schedule)
4847
// Schedule site stat updates for each wiki and platform-summary
4948
$schedule->command('schedule:stats')->dailyAt('7:00');
5049

50+
// https://laravel.com/docs/10.x/upgrade#redis-cache-tags
51+
$schedule->command('cache:prune-stale-tags')->hourly();
52+
5153
$schedule->job(new PollForMediaWikiJobsJob)->everyFifteenMinutes();
5254

5355
$schedule->job(new UpdateWikiSiteStatsJob)->dailyAt('19:00');
@@ -57,10 +59,8 @@ protected function schedule(Schedule $schedule)
5759

5860
/**
5961
* Register the commands for the application.
60-
*
61-
* @return void
6262
*/
63-
protected function commands()
63+
protected function commands(): void
6464
{
6565
$this->load(__DIR__.'/Commands');
6666
$this->load(__DIR__.'/Commands/User');

app/Exceptions/Handler.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,8 @@
77

88
class Handler extends ExceptionHandler
99
{
10-
11-
/**
12-
* A list of exception types with their corresponding custom log levels.
13-
*
14-
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
15-
*/
16-
protected $levels = [
17-
//
18-
];
19-
2010
/**
21-
* A list of the exception types that are not reported.
22-
*
23-
* @var array<int, class-string<\Throwable>>
24-
*/
25-
protected $dontReport = [];
26-
27-
/**
28-
* A list of the inputs that are never flashed for validation exceptions.
11+
* The list of the inputs that are never flashed to the session on validation exceptions.
2912
*
3013
* @var array
3114
*/
@@ -37,10 +20,11 @@ class Handler extends ExceptionHandler
3720
/**
3821
* Register the exception handling callbacks for the application.
3922
*/
40-
public function register()
23+
public function register(): void
4124
{
4225
$this->reportable(function (Throwable $e) {
4326
(new \Absszero\ErrorReporting)->report($e);
4427
});
4528
}
4629
}
30+

app/Http/Controllers/Controller.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
namespace App\Http\Controllers;
44

55
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
6-
use Illuminate\Foundation\Bus\DispatchesJobs;
76
use Illuminate\Foundation\Validation\ValidatesRequests;
87
use Illuminate\Routing\Controller as BaseController;
98

109
class Controller extends BaseController
1110
{
12-
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
11+
use AuthorizesRequests, ValidatesRequests;
1312
}

app/Http/Controllers/Sandbox/SandboxController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ public function create(Request $request): \Illuminate\Http\Response
8686
// For now only schedule this job for 1 dataSet type
8787
// As the extension API is dumb currently
8888
if ($dataSet === 'library') {
89-
$this->dispatch(new MediawikiSandboxLoadData($domain, $dataSet));
89+
dispatch(new MediawikiSandboxLoadData($domain, $dataSet));
9090
}
9191

9292
// opportunistic dispatching of jobs to make sure storage pools are topped up
93-
$this->dispatch(new ProvisionWikiDbJob(null, null, 10));
94-
$this->dispatch(new ProvisionQueryserviceNamespaceJob(null, 10));
93+
dispatch(new ProvisionWikiDbJob(null, null, 10));
94+
dispatch(new ProvisionQueryserviceNamespaceJob(null, 10));
9595

9696
$res['success'] = true;
9797
$res['message'] = 'Success!';

app/Http/Controllers/WikiController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function create(Request $request): \Illuminate\Http\Response
6868
$maxWikis = config('wbstack.wiki_max_per_user');
6969

7070
if ( config('wbstack.wiki_max_per_user') !== false && $numWikis > config('wbstack.wiki_max_per_user')) {
71-
abort(403, "Too many wikis. Your new total of {$numWikis} would exceed the limit of ${maxWikis} per user.");
71+
abort(403, "Too many wikis. Your new total of {$numWikis} would exceed the limit of {$maxWikis} per user.");
7272
}
7373

7474
$wiki = Wiki::create([
@@ -114,22 +114,22 @@ public function create(Request $request): \Illuminate\Http\Response
114114
]);
115115

116116
// TODO maybe always make these run in a certain order..?
117-
$this->dispatch(new MediawikiInit($wiki->domain, $request->input('username'), $user->email));
117+
dispatch(new MediawikiInit($wiki->domain, $request->input('username'), $user->email));
118118
// Only dispatch a job to add a k8s ingress IF we are using a custom domain...
119119
if (! $isSubdomain) {
120-
$this->dispatch(new KubernetesIngressCreate($wiki->id, $wiki->domain));
120+
dispatch(new KubernetesIngressCreate($wiki->id, $wiki->domain));
121121
}
122122
});
123123

124124

125125
// dispatch elasticsearch init job to enable the feature
126126
if ( Config::get('wbstack.elasticsearch_enabled_by_default') ) {
127-
$this->dispatch(new ElasticSearchIndexInit($wiki->id));
127+
dispatch(new ElasticSearchIndexInit($wiki->id));
128128
}
129129

130130
// opportunistic dispatching of jobs to make sure storage pools are topped up
131-
$this->dispatch(new ProvisionWikiDbJob(null, null, 10));
132-
$this->dispatch(new ProvisionQueryserviceNamespaceJob(null, 10));
131+
dispatch(new ProvisionWikiDbJob(null, null, 10));
132+
dispatch(new ProvisionQueryserviceNamespaceJob(null, 10));
133133

134134
$res['success'] = true;
135135
$res['message'] = 'Success!';

app/Http/Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Kernel extends HttpKernel
1414
* @var array
1515
*/
1616
protected $middleware = [
17-
\Fruitcake\Cors\HandleCors::class,
17+
\Illuminate\Http\Middleware\HandleCors::class,
1818
\Illuminate\Http\Middleware\TrustProxies::class,
1919
];
2020

@@ -32,7 +32,7 @@ class Kernel extends HttpKernel
3232
*
3333
* @var array
3434
*/
35-
protected $routeMiddleware = [
35+
protected $middlewareAliases = [
3636
// Came with Laravel
3737
'auth' => \App\Http\Middleware\Authenticate::class,
3838
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,

0 commit comments

Comments
 (0)