WP_Application_Passwords::check_password( string $password, string $hash ): bool
- Since
- 6.8.0
- Source
wp-includes/class-wp-application-passwords.php:500
Compatibility
- WordPress
- since 6.8.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in 4 of the 5 tracked releases, added in 6.8.0, and compiles on PHP 7.4 through 8.6-dev.
Parameters
$passwordstring- Plaintext password.
$hashstring- Hash of the password to check against.
Return value
bool- Whether the password matches the hashed password.
Performance profile
How much work a call to WP_Application_Passwords::check_password() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 10
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 16.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()one call below WP_Application_Passwords::check_password()
What one call costs · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Application_Passwords::check_password() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$hash | 10 | wp_verify_fast_hash() |
!$hash | 10 | wp_check_password() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 16 | 10 | 1 | |
| 8.5 | 16 | 10 | 1 | |
| 8.4 | 16 | 10 | 1 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 19 | 13 | 1 | |
| 8.2 | 19 | 13 | 1 | |
| 8.1 | 19 | 13 | 1 | |
| 7.4 | 19 | 13 | 1 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 3
- str_starts_with()Polyfill for `str_starts_with()` function added in PHP 8.0.
- wp_check_password()Checks a plaintext password against a hashed password.
- wp_verify_fast_hash()Checks whether a plaintext message matches the hashed value. Used to verify values hashed via wp_fast_hash().
Used by · 1
- wp_authenticate_application_password()Authenticates the user using an application password.
Source code
public static function check_password( #[\SensitiveParameter] string $password, string $hash ): bool { if ( ! str_starts_with( $hash, '$generic$' ) ) { /* * If the hash doesn't start with `$generic$`, it is a hash created with `wp_hash_password()`. * This is the case for application passwords created before 6.8.0. */ return wp_check_password( $password, $hash ); } return wp_verify_fast_hash( $password, $hash ); }Changelog
Introduced in 6.8.0. Unchanged from 6.8.8 through 7.1.0.
Signature, return type and hooks compared across 4 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-application-passwords.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.