From 68aeca4f644033391bf5450a30d3ba104b6b7110 Mon Sep 17 00:00:00 2001 From: Diana Scharf Date: Fri, 7 Mar 2025 09:34:56 +0100 Subject: [PATCH 1/4] Workflow trigger --- .github/workflows/run-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4769dc8..7bf6309 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -3,6 +3,7 @@ name: run-tests on: - push - pull_request + - workflow_dispatch jobs: test: From e731b368082f4041a1810e98271a87ece0191e01 Mon Sep 17 00:00:00 2001 From: Anton Cherednichenko Date: Tue, 1 Apr 2025 15:57:52 +0200 Subject: [PATCH 2/4] Fix for a deprecated parameter: "Implicitly marking parameter $container as nullable is deprecated, the explicit nullable type must be used instead" --- src/Routing/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Routing/Router.php b/src/Routing/Router.php index 216ac71..4b32946 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -24,7 +24,7 @@ class Router /** @var Container */ protected $container; - public function __construct(?Container $container = null) + public function __construct(?Container $container) { $this->container = $container ?: new Container; From 7d5da44e272e16da84f2ece0a10d53c6d14e2b2e Mon Sep 17 00:00:00 2001 From: Cameron Wilby Date: Sat, 14 Jun 2025 14:21:09 -0700 Subject: [PATCH 3/4] Change CleanEmailsTest to create 200 emails --- tests/Console/CleanEmailsTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Console/CleanEmailsTest.php b/tests/Console/CleanEmailsTest.php index 78f88cd..5f18272 100644 --- a/tests/Console/CleanEmailsTest.php +++ b/tests/Console/CleanEmailsTest.php @@ -23,14 +23,14 @@ public function setUp(): void /** @test */ public function it_can_clean_the_statistics() { - Collection::times(60)->each(function (int $index) { + Collection::times(200)->each(function (int $index) { InboundEmail::forceCreate([ 'message' => Str::random(), 'created_at' => Carbon::now()->subDays($index)->startOfDay(), ]); }); - $this->assertCount(60, InboundEmail::all()); + $this->assertCount(200, InboundEmail::all()); Artisan::call('mailbox:clean'); @@ -46,19 +46,19 @@ public function it_errors_if_max_age_inf() { $this->app['config']->set('mailbox.store_incoming_emails_for_days', INF); - Collection::times(60)->each(function (int $index) { + Collection::times(200)->each(function (int $index) { InboundEmail::forceCreate([ 'message' => Str::random(), 'created_at' => Carbon::now()->subDays($index)->startOfDay(), ]); }); - $this->assertCount(60, InboundEmail::all()); + $this->assertCount(200, InboundEmail::all()); $this->artisan('mailbox:clean') ->expectsOutput('mailbox:clean is disabled because store_incoming_emails_for_days is set to INF.') ->assertExitCode(1); - $this->assertCount(60, InboundEmail::all()); + $this->assertCount(200, InboundEmail::all()); } } From e69ad082dad4fe291bf4c1fbc7152004cc16a44c Mon Sep 17 00:00:00 2001 From: Cameron Wilby Date: Sat, 14 Jun 2025 14:35:31 -0700 Subject: [PATCH 4/4] Use eachById when cleaning emails --- src/Console/CleanEmails.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Console/CleanEmails.php b/src/Console/CleanEmails.php index 8cd8e3c..d682313 100644 --- a/src/Console/CleanEmails.php +++ b/src/Console/CleanEmails.php @@ -37,12 +37,9 @@ public function handle() $modelClass::where('created_at', '<', $cutOffDate) ->select('id') - ->chunk(100, function ($models) use ($modelClass) { - foreach ($models as $model) { - $modelInstance = $modelClass::find($model->id); - $modelInstance->delete(); - $this->amountDeleted++; - } + ->eachById(count: 100, callback: function ($model) { + $model->delete(); + $this->amountDeleted++; }); $this->info("Deleted {$this->amountDeleted} record(s) from the Mailbox logs.");