- md5
- d5720df5f4a82b31da6f22cc667b0d6d
- sha1
- b7c3f75bf7a2024ee5fddd41780f917c9cdc09f7
- sha256
- 178f7743dc24c25f1eb6c9d25254486f5b3b3fb19649a63d6710148a02183e17
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
<?php
/**
* Secrets API: WP_Secrets_Broken_Provider class
*
* @package WordPress
* @subpackage Secrets
* @since 7.2.0
*/
/**
* The provider installed when a secrets.php drop-in did not load correctly.
*
* Every operation returns WP_Error. It exists so that a broken drop-in cannot be
* mistaken for a working site with no secrets in it yet – which is the failure
* mode that turns "my credential backend is misconfigured" into "my credentials
* appear to have been deleted," and is precisely what this API's three-state return
* exists to prevent.
*
* Deliberately not a fallback to the default provider. Reverting to local storage
* because a host's KMS drop-in failed would quietly downgrade a site's protection
* at the exact moment nobody is watching.
*
* @since 7.2.0
*/
final class WP_Secrets_Broken_Provider extends WP_Secrets_Provider {
/**
* The single error every operation reports.
*
* @since 7.2.0
*
* @return WP_Error
*/
private function error(): WP_Error {
return new WP_Error(
WP_SECRETS_ERROR_STORE_UNAVAILABLE,
__( 'The secrets.php drop-in did not load correctly, so no secret can be read or written. Fix or remove the drop-in.' )
);
}
/**
* Always an error.
*
* @since 7.2.0
*
* @param string $name The secret's name.
* @param string $version A WP_Secret_Version constant.
* @param bool $network Whether this is a network-scope secret.
* @return WP_Error
*
* @phpstan-param WP_Secret_Version::CURRENT|WP_Secret_Version::PREVIOUS $version
*/
public function get( string $name, string $version, bool $network = false ): WP_Error {
return $this->error();
}
/**
* Always an error.
*
* @since 7.2.0
*
* @param string $name The secret's name.
* @param string $value The plaintext value.
* @param bool $network Whether this is a network-scope secret.
* @param bool $needs_rotation Ignored.
* @param string|null $action Ignored.
* @return WP_Error
*/
public function set(
string $name,
#[\SensitiveParameter]
$value,
bool $network = false,
bool $needs_rotation = false,
?string $action = null
): WP_Error {
return $this->error();
}
/**
* Always an error.
*
* @since 7.2.0
*
* @param string $name The secret's name.
* @param bool $network Whether this is a network-scope secret.
* @return WP_Error
*/
public function delete( string $name, bool $network = false ): WP_Error {
return $this->error();
}
/**
* Always an error.
*
* @since 7.2.0
*
* @param string $name The secret's name.
* @param bool $network Whether this is a network-scope secret.
* @return WP_Error
*/
public function retire_previous( string $name, bool $network = false ): WP_Error {
return $this->error();
}
/**
* Always an error.
*
* @since 7.2.0
*
* @param string $name_prefix Restrict to names beginning with this prefix.
* @param bool $network Whether to list network-scope secrets.
* @return WP_Error
*/
public function list_secrets( string $name_prefix = '', bool $network = false ): WP_Error {
return $this->error();
}
/**
* Says plainly that the drop-in is the problem.
*
* @since 7.2.0
*
* @return string
*/
public function get_label(): string {
return __( 'Unavailable: the secrets.php drop-in did not load correctly' );
}
/**
* Reports the provider boundary.
*
* Whatever was meant to protect these secrets is not WordPress, and is not
* working.
*
* @since 7.2.0
*
* @return string
*
* @phpstan-return self::BOUNDARY_*
*/
public function get_protection_boundary(): string {
return self::BOUNDARY_PROVIDER;
}
/**
* Nothing is writable while the drop-in is broken.
*
* @since 7.2.0
*
* @return bool
*/
public function is_writable(): bool {
return false;
}
}
No other release has this exact content. See every version of this file.