Skip to content

Commit

Permalink
Whip_MessageDismisser::verifyNonce(): bug fix
Browse files Browse the repository at this point in the history
The method is documented as returning a boolean value, but the `wp_verify_nonce()` function returns `int|false`.

Fixed now.

Ref: https://developer.wordpress.org/reference/functions/wp_verify_nonce/

Note: as the test suite does not test with a real WP setup, this bug currently cannot easily be proven, nor safeguarded via a test.

The `WHIP_WPMessageDismissListener::listen()` method uses this function and does have a test, but mocks away the `Whip_MessageDismisser::verifyNonce()` method. The mock correctly returns `true|false`, but that isn't what the reality was doing.
  • Loading branch information
jrfnl committed Sep 26, 2023
1 parent 06b74c8 commit df952b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Whip_MessageDismisser.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ public function isDismissed() {
* @return bool True when the nonce is valid.
*/
public function verifyNonce( $nonce, $action ) {
return wp_verify_nonce( $nonce, $action );
return (bool) wp_verify_nonce( $nonce, $action );
}
}

0 comments on commit df952b2

Please sign in to comment.