| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Secrets API: WP_Secrets_Broken_Provider class 4 * 5 * @package WordPress 6 * @subpackage Secrets 7 * @since 7.2.0 8 */ 9 10 /** 11 * The provider installed when a secrets.php drop-in did not load correctly. 12 * 13 * Every operation returns WP_Error. It exists so that a broken drop-in cannot be 14 * mistaken for a working site with no secrets in it yet – which is the failure 15 * mode that turns "my credential backend is misconfigured" into "my credentials 16 * appear to have been deleted," and is precisely what this API's three-state return 17 * exists to prevent. 18 * 19 * Deliberately not a fallback to the default provider. Reverting to local storage 20 * because a host's KMS drop-in failed would quietly downgrade a site's protection 21 * at the exact moment nobody is watching. 22 * 23 * @since 7.2.0 24 */ 25 final class WP_Secrets_Broken_Provider extends WP_Secrets_Provider { 26 27 /** 28 * The single error every operation reports. 29 * 30 * @since 7.2.0 31 * 32 * @return WP_Error 33 */ 34 private function error(): WP_Error { 35 return new WP_Error( 36 WP_SECRETS_ERROR_STORE_UNAVAILABLE, 37 __( 'The secrets.php drop-in did not load correctly, so no secret can be read or written. Fix or remove the drop-in.' ) 38 ); 39 } 40 41 /** 42 * Always an error. 43 * 44 * @since 7.2.0 45 * 46 * @param string $name The secret's name. 47 * @param string $version A WP_Secret_Version constant. 48 * @param bool $network Whether this is a network-scope secret. 49 * @return WP_Error 50 * 51 * @phpstan-param WP_Secret_Version::CURRENT|WP_Secret_Version::PREVIOUS $version 52 */ 53 public function get( string $name, string $version, bool $network = false ): WP_Error { 54 return $this->error(); 55 } 56 57 /** 58 * Always an error. 59 * 60 * @since 7.2.0 61 * 62 * @param string $name The secret's name. 63 * @param string $value The plaintext value. 64 * @param bool $network Whether this is a network-scope secret. 65 * @param bool $needs_rotation Ignored. 66 * @param string|null $action Ignored. 67 * @return WP_Error 68 */ 69 public function set( 70 string $name, 71 #[\SensitiveParameter] 72 $value, 73 bool $network = false, 74 bool $needs_rotation = false, 75 ?string $action = null 76 ): WP_Error { 77 return $this->error(); 78 } 79 80 /** 81 * Always an error. 82 * 83 * @since 7.2.0 84 * 85 * @param string $name The secret's name. 86 * @param bool $network Whether this is a network-scope secret. 87 * @return WP_Error 88 */ 89 public function delete( string $name, bool $network = false ): WP_Error { 90 return $this->error(); 91 } 92 93 /** 94 * Always an error. 95 * 96 * @since 7.2.0 97 * 98 * @param string $name The secret's name. 99 * @param bool $network Whether this is a network-scope secret. 100 * @return WP_Error 101 */ 102 public function retire_previous( string $name, bool $network = false ): WP_Error { 103 return $this->error(); 104 } 105 106 /** 107 * Always an error. 108 * 109 * @since 7.2.0 110 * 111 * @param string $name_prefix Restrict to names beginning with this prefix. 112 * @param bool $network Whether to list network-scope secrets. 113 * @return WP_Error 114 */ 115 public function list_secrets( string $name_prefix = '', bool $network = false ): WP_Error { 116 return $this->error(); 117 } 118 119 /** 120 * Says plainly that the drop-in is the problem. 121 * 122 * @since 7.2.0 123 * 124 * @return string 125 */ 126 public function get_label(): string { 127 return __( 'Unavailable: the secrets.php drop-in did not load correctly' ); 128 } 129 130 /** 131 * Reports the provider boundary. 132 * 133 * Whatever was meant to protect these secrets is not WordPress, and is not 134 * working. 135 * 136 * @since 7.2.0 137 * 138 * @return string 139 * 140 * @phpstan-return self::BOUNDARY_* 141 */ 142 public function get_protection_boundary(): string { 143 return self::BOUNDARY_PROVIDER; 144 } 145 146 /** 147 * Nothing is writable while the drop-in is broken. 148 * 149 * @since 7.2.0 150 * 151 * @return bool 152 */ 153 public function is_writable(): bool { 154 return false; 155 } 156 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Mon Nov 16 08:20:01 2026 | Cross-referenced by PHPXref |