From 9f7c2d9aba576905c066604e0ab6c7b70889bc28 Mon Sep 17 00:00:00 2001 From: Jan-Niclas Loosen Date: Wed, 4 Nov 2026 15:36:30 +0100 Subject: [PATCH] =?UTF-8?q?feat(updater):=20Update-Pr=C3=BCfung=20nach=20I?= =?UTF-8?q?nstallation=20oder=20Versionswechsel=20neu=20ausl=C3=B6sen,=20V?= =?UTF-8?q?ersion=201.0.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- readme.txt | 5 +- src/Plugin.php | 4 +- src/Uninstaller.php | 5 +- src/Updater/RecheckOnInstall.php | 38 +++++++++++++++ tests/Unit/UninstallTest.php | 2 + tests/Unit/UninstallerTest.php | 2 + tests/Unit/Updater/RecheckOnInstallTest.php | 51 +++++++++++++++++++++ wp-lit-mcp.php | 2 +- 8 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 src/Updater/RecheckOnInstall.php create mode 100644 tests/Unit/Updater/RecheckOnInstallTest.php diff --git a/readme.txt b/readme.txt index 7eddcde..3b1a01c 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: mcp, ai, divi, pods, oauth Requires at least: 6.9 Tested up to: 7.1 Requires PHP: 8.1 -Stable tag: 1.0.4 +Stable tag: 1.0.5 License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -209,6 +209,9 @@ LIT MCP schreibt nur mit Divi-Versionen, die für diese Plugin-Version geprüft == Changelog == += 1.0.5 = +* Nach einer Installation oder einem Versionswechsel prüft WordPress sofort neu auf Updates, damit der Schalter für automatische Updates gleich erscheint. + = 1.0.4 = * Kürzere Beschreibung in der Plugin-Liste. diff --git a/src/Plugin.php b/src/Plugin.php index 83652a8..8772791 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -38,6 +38,7 @@ use LIT\MCP\Server\RequestContext; use LIT\MCP\Server\ServerRegistrar; use LIT\MCP\Server\VisibilityFilter; use LIT\MCP\Updater\GiteaUpdater; +use LIT\MCP\Updater\RecheckOnInstall; defined('ABSPATH') || exit; @@ -46,7 +47,7 @@ defined('ABSPATH') || exit; */ final class Plugin { - public const VERSION = '1.0.4'; + public const VERSION = '1.0.5'; private static string $pluginFile = ''; private static ?SettingsPage $settingsPage = null; @@ -57,6 +58,7 @@ final class Plugin // Before the dependency check: a plugin that is inactive for a missing dependency must still be updatable. (new GiteaUpdater(plugin_basename($pluginFile), dirname($pluginFile)))->register(); + (new RecheckOnInstall(self::VERSION))->register(); $missing = (new Dependencies())->missing(); if ($missing !== []) { diff --git a/src/Uninstaller.php b/src/Uninstaller.php index 8dec63f..c7d0588 100644 --- a/src/Uninstaller.php +++ b/src/Uninstaller.php @@ -20,8 +20,8 @@ defined('ABSPATH') || exit; * ReleaseStore::OPTION, Integrations\Divi\Release\CheckReportStore::OPTION, Integrations\ * Divi\Release\DiviCheckRoute::LOCK, Integrations\Divi\Design\DesignLock::option(), * Admin\ConnectionStatus::ENDPOINT_TRANSIENT, Integrations\Divi\Release\ReleaseResolver::CACHE, - * ChangeLog\ChangeLogCleanup::HOOK, ChangeLog\ChangeLog::TABLE and Admin\LogTab::PER_PAGE_OPTION - * on purpose; + * ChangeLog\ChangeLogCleanup::HOOK, ChangeLog\ChangeLog::TABLE, Admin\LogTab::PER_PAGE_OPTION and + * Updater\RecheckOnInstall::OPTION on purpose; * tests/Unit/UninstallerTest.php and tests/Unit/UninstallTest.php keep them in sync with * those constants. * @@ -40,6 +40,7 @@ final class Uninstaller 'lit_mcp_lock_divi_options', 'lit_mcp_lock_variables', 'lit_mcp_lock_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', + 'lit_mcp_installed_version', ]; private const TRANSIENTS = ['lit_mcp_endpoint_check', 'lit_mcp_divi_state']; private const CRON_HOOK = 'lit_mcp_log_cleanup'; diff --git a/src/Updater/RecheckOnInstall.php b/src/Updater/RecheckOnInstall.php new file mode 100644 index 0000000..88ae7c8 --- /dev/null +++ b/src/Updater/RecheckOnInstall.php @@ -0,0 +1,38 @@ +version) { + return; + } + + delete_site_transient('update_plugins'); + update_option(self::OPTION, $this->version, false); + } +} diff --git a/tests/Unit/UninstallTest.php b/tests/Unit/UninstallTest.php index 35b8f71..4052f92 100644 --- a/tests/Unit/UninstallTest.php +++ b/tests/Unit/UninstallTest.php @@ -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); diff --git a/tests/Unit/UninstallerTest.php b/tests/Unit/UninstallerTest.php index 3620196..d0981c3 100644 --- a/tests/Unit/UninstallerTest.php +++ b/tests/Unit/UninstallerTest.php @@ -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 ); diff --git a/tests/Unit/Updater/RecheckOnInstallTest.php b/tests/Unit/Updater/RecheckOnInstallTest.php new file mode 100644 index 0000000..b685a8a --- /dev/null +++ b/tests/Unit/Updater/RecheckOnInstallTest.php @@ -0,0 +1,51 @@ +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 */ + 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(); + } +} diff --git a/wp-lit-mcp.php b/wp-lit-mcp.php index 01dbb23..208ddb2 100644 --- a/wp-lit-mcp.php +++ b/wp-lit-mcp.php @@ -4,7 +4,7 @@ * Plugin Name: WP-LIT-MCP * Plugin URI: https://git.loosen-it.de/janniclas.loosen/WP-LIT-MCP * Description: MCP-Server für WordPress, Divi 5 und Pods. Pflegt Inhalte, Medien und Divi-Seiten mit OAuth für KI-Assistenten. - * Version: 1.0.4 + * Version: 1.0.5 * Update URI: https://git.loosen-it.de/janniclas.loosen/WP-LIT-MCP * Requires at least: 6.9 * Requires PHP: 8.1