[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/secrets/ -> class-wp-secrets-broken-keyring.php (source)

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


Generated : Mon Nov 16 08:20:01 2026 Cross-referenced by PHPXref