Repository navigation
Expand file tree
/
Copy pathclass-wp-secrets-broken-keyring.php
More file actions
76 lines (71 loc) · 1.6 KB
/
Copy pathclass-wp-secrets-broken-keyring.php
File metadata and controls
76 lines (71 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* Secrets API: WP_Secrets_Broken_Keyring class
*
* @package WordPress
* @subpackage Secrets
* @since 7.2.0
*/
/**
* Stands in for the keyring when a drop-in leaves an invalid value behind.
*
* Installed when a secrets.php drop-in exists but $GLOBALS['wp_secrets_keyring'] does
* not hold a WP_Secrets_Keyring.
*
* Same reasoning as WP_Secrets_Broken_Store: the drop-in's presence signals the
* operator wants a keyring other than the default, so silently falling back to
* WP_Secrets_Config_Key_Provider would wrap the root key under a key the operator
* did not choose. Every operation fails closed instead.
*
* @since 7.2.0
*/
final class WP_Secrets_Broken_Keyring extends WP_Secrets_Keyring {
/**
* Always fails closed.
*
* @since 7.2.0
*
* @param string $key_material Ignored.
* @return WP_Error
*/
public function wrap(
#[\SensitiveParameter]
string $key_material
): WP_Error {
return $this->error();
}
/**
* Always fails closed.
*
* @since 7.2.0
*
* @param string $wrapped Ignored.
* @return WP_Error
*/
public function unwrap( string $wrapped ): WP_Error {
return $this->error();
}
/**
* Describes the broken state, for Site Health.
*
* @since 7.2.0
*
* @return string
*/
public function get_key_source(): string {
return __( 'broken secrets.php drop-in' );
}
/**
* Builds the error every method returns.
*
* @since 7.2.0
*
* @return WP_Error
*/
private function error(): WP_Error {
return new WP_Error(
WP_SECRETS_ERROR_KEY_UNAVAILABLE,
__( 'The secrets.php drop-in did not provide a usable keyring.' )
);
}
}