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