Skip to content

Commit d428653

Browse files
committed
store and check update requirement state
1 parent f074ed5 commit d428653

File tree

8 files changed

+59
-10
lines changed

8 files changed

+59
-10
lines changed

app/Console/Commands/PerformUpdate.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public function handle(): int
3535
/** @var Site $site */
3636
$site = Site::findOrFail($this->input->getArgument('siteId'));
3737

38+
if (!$site->update_requirement_state) {
39+
$this->output->writeln('Update requirements not met, aborting!');
40+
41+
return Command::FAILURE;
42+
}
43+
3844
UpdateSite::dispatchSync(
3945
$site,
4046
$targetVersion

app/Console/Commands/QueueUpdates.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function handle(): int
3939
$this->output->writeln('Pushing update jobs');
4040

4141
$sites = Site::query()
42+
->where('update_requirement_state', '=', true)
4243
->where(
4344
'cms_version',
4445
'like',

app/Jobs/CheckSiteHealth.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public function handle(): void
4242
$this->site->last_seen = Carbon::now();
4343
$this->site->save();
4444

45+
// Check if conditions are met
46+
// @phpstan-ignore-next-line
47+
if (!$this->site->update_requirement_state) {
48+
return;
49+
}
50+
4551
// Check if a newer Joomla version for that site is available
4652
/** @var TufFetcher $tufFetcher */
4753
$tufFetcher = App::make(TufFetcher::class);

app/Jobs/UpdateSite.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public function handle(): void
5151
return;
5252
}
5353

54+
if (!$healthResult->update_requirement_state) {
55+
Log::info("Site does not meet requirements, abort");
56+
57+
return;
58+
}
59+
5460
// Do not make a major version update
5561
$majorVersionCms = (int) $healthResult->cms_version;
5662
$majorTargetVersion = (int) $this->targetVersion;

app/Models/Site.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ class Site extends Model
2020
'db_version',
2121
'cms_version',
2222
'server_os',
23-
'update_patch',
24-
'update_minor',
25-
'update_major'
23+
'update_requirement_state'
2624
];
2725

2826
protected $hidden = [
@@ -33,9 +31,7 @@ protected function casts(): array
3331
{
3432
return [
3533
'last_seen' => 'datetime',
36-
'update_patch' => 'bool',
37-
'update_minor' => 'bool',
38-
'update_major' => 'bool'
34+
'update_requirement_state' => 'bool',
3935
];
4036
}
4137

app/RemoteSite/Responses/HealthCheck.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ public function __construct(
1111
public string $db_type,
1212
public string $db_version,
1313
public string $cms_version,
14-
public string $server_os
14+
public string $server_os,
15+
public bool $update_requirement_state
1516
) {
1617
}
1718
}

database/migrations/2024_11_15_191942_create_sites_table.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ public function up(): void
1919
$table->string('db_version');
2020
$table->string('cms_version')->index();
2121
$table->string('server_os');
22-
$table->boolean('update_patch');
23-
$table->boolean('update_minor');
24-
$table->boolean('update_major');
2522
$table->dateTime('last_seen');
2623
$table->timestamps();
2724
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('sites', function (Blueprint $table) {
15+
$table->boolean('update_requirement_state')->default(false)->nullable(true);
16+
17+
$table->dropColumn('update_patch');
18+
$table->dropColumn('update_minor');
19+
$table->dropColumn('update_major');
20+
});
21+
}
22+
23+
/**
24+
* Reverse the migrations.
25+
*/
26+
public function down(): void
27+
{
28+
Schema::table('sites', function (Blueprint $table) {
29+
$table->dropColumn('update_requirement_state');
30+
31+
$table->boolean('update_patch');
32+
$table->boolean('update_minor');
33+
$table->boolean('update_major');
34+
});
35+
}
36+
};

0 commit comments

Comments
 (0)