fix: discovery admin notice fires on cached 'recommended' too, guarded against oauth/permalink early returns
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -30,8 +30,24 @@ final class AdminNotices
|
||||
) . ' ' . __('Claude kann sich nicht verbinden.', 'wp-lit-mcp');
|
||||
}
|
||||
|
||||
/*
|
||||
* Fire whenever the cached discovery result is not 'good' (this also covers
|
||||
* 'recommended', which is how HealthCheck::run_self_check() itself reports both
|
||||
* a genuine reachability problem and its acme-challenge-fingerprint "critical"
|
||||
* case) — but only when oauth is enabled and permalinks are pretty. Those two
|
||||
* conditions are exactly when run_self_check() short-circuits to its own
|
||||
* disabled/permalink-missing early returns instead of a real check; guarding on
|
||||
* them here (rather than trying to recognise their shape from the cached array)
|
||||
* keeps this correct even though, in the vendor's current implementation,
|
||||
* neither early return is ever persisted to the transient we read.
|
||||
*/
|
||||
$discovery = $this->status->discovery(false);
|
||||
if (is_array($discovery) && ($discovery['status'] ?? 'good') === 'critical') {
|
||||
if (
|
||||
$this->status->oauthEnabled()
|
||||
&& $this->status->permalinksPretty()
|
||||
&& is_array($discovery)
|
||||
&& ($discovery['status'] ?? 'good') !== 'good'
|
||||
) {
|
||||
$messages[] = __(
|
||||
'LIT MCP: Die OAuth-Discovery-Dokumente unter /.well-known/ sind nicht erreichbar.',
|
||||
'wp-lit-mcp'
|
||||
|
||||
@@ -46,6 +46,17 @@ class ConnectionStatus
|
||||
return str_starts_with((string) home_url(), 'https://');
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a pretty permalink structure is active. HealthCheck::run_self_check()
|
||||
* short-circuits to a 'recommended' result (never persisted to its transient)
|
||||
* when this is false; used to tell that early return apart from a genuine
|
||||
* discovery failure without depending on that vendor implementation detail.
|
||||
*/
|
||||
public function permalinksPretty(): bool
|
||||
{
|
||||
return (string) get_option('permalink_structure') !== '';
|
||||
}
|
||||
|
||||
/** @return array<string, mixed>|null mcp-oauth's discovery self check (label, status, …). */
|
||||
public function discovery(bool $allowFetch): ?array
|
||||
{
|
||||
@@ -101,28 +112,36 @@ class ConnectionStatus
|
||||
$endpoint = $this->endpoint($allowFetch);
|
||||
|
||||
return [
|
||||
['label' => 'MCP-Adapter', 'ok' => $adapter, 'message' => $adapter ? 'geladen' : 'fehlt'],
|
||||
[
|
||||
'label' => 'OAuth-Server',
|
||||
'label' => __('MCP-Adapter', 'wp-lit-mcp'),
|
||||
'ok' => $adapter,
|
||||
'message' => $adapter ? __('geladen', 'wp-lit-mcp') : __('fehlt', 'wp-lit-mcp'),
|
||||
],
|
||||
[
|
||||
'label' => __('OAuth-Server', 'wp-lit-mcp'),
|
||||
'ok' => $oauth,
|
||||
'message' => $oauth ? 'aktiv' : 'deaktiviert (Filter wpmedia_mcp_oauth_server_enabled)',
|
||||
'message' => $oauth
|
||||
? __('aktiv', 'wp-lit-mcp')
|
||||
: __('deaktiviert (Filter wpmedia_mcp_oauth_server_enabled)', 'wp-lit-mcp'),
|
||||
],
|
||||
[
|
||||
'label' => 'HTTPS',
|
||||
'label' => __('HTTPS', 'wp-lit-mcp'),
|
||||
'ok' => $https,
|
||||
'message' => $https ? 'aktiv' : 'Website läuft ohne HTTPS – claude.ai verbindet sich nur über HTTPS',
|
||||
'message' => $https
|
||||
? __('aktiv', 'wp-lit-mcp')
|
||||
: __('Website läuft ohne HTTPS – claude.ai verbindet sich nur über HTTPS', 'wp-lit-mcp'),
|
||||
],
|
||||
[
|
||||
'label' => 'Discovery (/.well-known/)',
|
||||
'label' => __('Discovery (/.well-known/)', 'wp-lit-mcp'),
|
||||
'ok' => $discovery === null ? null : ($discovery['status'] ?? '') === 'good',
|
||||
'message' => $discovery === null
|
||||
? 'noch nicht geprüft'
|
||||
? __('noch nicht geprüft', 'wp-lit-mcp')
|
||||
: wp_strip_all_tags((string) ($discovery['label'] ?? '')),
|
||||
],
|
||||
[
|
||||
'label' => 'Endpunkt ohne Token',
|
||||
'label' => __('Endpunkt ohne Token', 'wp-lit-mcp'),
|
||||
'ok' => $endpoint['ok'] ?? null,
|
||||
'message' => $endpoint['message'] ?? 'noch nicht geprüft',
|
||||
'message' => $endpoint['message'] ?? __('noch nicht geprüft', 'wp-lit-mcp'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user