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
+3 -1
View File
@@ -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 !== []) {
+3 -2
View File
@@ -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';
+38
View File
@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Updater;
defined('ABSPATH') || exit;
/**
* Makes WordPress check for updates again right after this plugin was installed or replaced. An install deletes
* the stored update result, and a check that runs while the plugin is not loaded stores one without it: the plugin
* list then hides the auto-update switch for up to an hour. The first admin request with the new code forgets the
* result at admin_init, before core's own _maybe_update_plugins (priority 10) rebuilds it, this time with
* GiteaUpdater registered.
*/
final class RecheckOnInstall
{
public const OPTION = 'lit_mcp_installed_version';
public function __construct(private string $version)
{
}
public function register(): void
{
add_action('admin_init', [$this, 'recheckIfNew'], 5);
}
public function recheckIfNew(): void
{
if (get_option(self::OPTION) === $this->version) {
return;
}
delete_site_transient('update_plugins');
update_option(self::OPTION, $this->version, false);
}
}