Yoast\WP\SEO\AI\Authentication\Application
AI_Request_Sender::is_fallback_eligible
Decides whether a primary-strategy failure may be retried via the fallback strategy.
The fallback exists to recover from a primary strategy that could not authenticate or reach the service. It must not fire on an authoritative answer the service gave about the request, the user, or the account, because the fallback talks to the same service for the same user and would either get the same answer or, worse, fail for an unrelated reason and mask the real one — for example a 400 content-filter rejection (profanity) would be silently turned into a repeat request.
Only three failures clear this gate, all of them about the primary strategy itself rather than the service's verdict: Auth_Strategy_Unavailable_Exception{} (no OAuth site token could be acquired), Unauthorized_Exception{} (a 401 — the token is missing, invalid, or expired), and WP_Request_Exception{} (a transport failure reaching the service, the very case OAuth exists to survive — note it carries status 400 by convention but is a transport failure, not a service answer). Every other Remote_Request_Exception{} — a service-issued 400 ([](), e.g. a content filter), 402, 403 (consent, scope, or any other forbidden), 404, 408, 429, 500, 503 — is an authoritative answer that propagates untouched.
Метод класса: AI_Request_Sender{}
Хуков нет.
Возвращает
bool. True when the fallback may be tried, false when the failure must propagate.
Использование
// private - только в коде основоного (родительского) класса $result = $this->is_fallback_eligible( $exception ): bool;
- $exception(Remote_Request_Exception) (обязательный)
- The failure thrown by the primary strategy.
Код AI_Request_Sender::is_fallback_eligible() AI Request Sender::is fallback eligible Yoast 28.9
private function is_fallback_eligible( Remote_Request_Exception $exception ): bool {
return $exception instanceof Auth_Strategy_Unavailable_Exception
|| $exception instanceof Unauthorized_Exception
|| $exception instanceof WP_Request_Exception;
}