feat(updater): Update-Prüfung nach Installation oder Versionswechsel neu auslösen, Version 1.0.5

Eine Installation löscht das gespeicherte Update-Ergebnis; eine Prüfung, die läuft, solange das Plugin
nicht geladen ist, speichert eines ohne das Plugin, und der Schalter für automatische Updates fehlt bis
zu eine Stunde. RecheckOnInstall vergisst das Ergebnis beim ersten admin_init mit der neuen Version
(Priorität 5, vor _maybe_update_plugins des Core), der es dann mit registriertem GiteaUpdater neu aufbaut.
Die Option lit_mcp_installed_version räumt der Uninstaller auf.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-11-04 15:36:30 +01:00
co-authored by Claude Sonnet 5.5
parent 62292a4846
commit 9f7c2d9aba
8 changed files with 104 additions and 5 deletions
+2
View File
@@ -16,6 +16,7 @@ use LIT\MCP\Integrations\Divi\Release\DiviCheckRoute;
use LIT\MCP\Integrations\Divi\Release\ReleaseResolver;
use LIT\MCP\Integrations\Divi\Release\ReleaseStore;
use LIT\MCP\Limits;
use LIT\MCP\Updater\RecheckOnInstall;
use Mockery;
final class UninstallTest extends TestCase
@@ -61,6 +62,7 @@ final class UninstallTest extends TestCase
DesignLock::option('colors'), DesignLock::option('variables'), DesignLock::option('presets'),
// Locks of versions before the shared one (audit L5) may still sit in the table.
'lit_mcp_lock_colors', 'lit_mcp_lock_theme_options',
RecheckOnInstall::OPTION,
];
self::assertSame(array_merge($own, $own), $deleted);
self::assertNotContains('mcp_jwt_secret', $deleted);
+2
View File
@@ -18,6 +18,7 @@ use LIT\MCP\Integrations\Divi\Release\ReleaseResolver;
use LIT\MCP\Integrations\Divi\Release\ReleaseStore;
use LIT\MCP\Limits;
use LIT\MCP\Uninstaller;
use LIT\MCP\Updater\RecheckOnInstall;
use Mockery;
/**
@@ -67,6 +68,7 @@ final class UninstallerTest extends TestCase
DesignLock::option('colors'), DesignLock::option('variables'), DesignLock::option('presets'),
// Locks of versions before the shared one (audit L5) may still sit in the table.
'lit_mcp_lock_colors', 'lit_mcp_lock_theme_options',
RecheckOnInstall::OPTION,
],
$deleted
);
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Updater;
use Brain\Monkey\Actions;
use Brain\Monkey\Functions;
use LIT\MCP\Tests\Unit\TestCase;
use LIT\MCP\Updater\RecheckOnInstall;
final class RecheckOnInstallTest extends TestCase
{
public function testRunsAtAdminInitBeforeCoreRebuildsTheUpdateResult(): void
{
$recheck = new RecheckOnInstall('1.0.5');
// Core's _maybe_update_plugins sits on admin_init at the default priority 10.
Actions\expectAdded('admin_init')->once()->with([$recheck, 'recheckIfNew'], 5);
$recheck->register();
}
/** @dataProvider installedBefore */
public function testForgetsTheUpdateResultWhenTheVersionIsNewToThisSite(string|false $stored): void
{
Functions\when('get_option')->justReturn($stored);
Functions\expect('delete_site_transient')->once()->with('update_plugins');
Functions\expect('update_option')->once()->with(RecheckOnInstall::OPTION, '1.0.5', false);
(new RecheckOnInstall('1.0.5'))->recheckIfNew();
}
/** @return array<string, array{string|false}> */
public static function installedBefore(): array
{
return [
'fresh install, nothing stored' => [false],
'replaced by a newer version' => ['1.0.4'],
'replaced by an older version' => ['1.0.9'],
];
}
public function testDoesNothingForTheVersionAlreadySeen(): void
{
Functions\when('get_option')->justReturn('1.0.5');
Functions\expect('delete_site_transient')->never();
Functions\expect('update_option')->never();
(new RecheckOnInstall('1.0.5'))->recheckIfNew();
}
}