Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whip_WPMessageDismissListener::listen(): bug fix #145

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Sep 26, 2023

The Whip_MessageDismisser::verifyNonce() method expects to be passed a string, but if the nonce was not available, it would be passed null, which could lead to PHP 8.1 "passing null to non-nullable" deprecation notices (though in this case wouldn't as the underlying wp_verify_nonce() function casts the value to string anyway).

All the same, it is a bug. Fixed now.

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

The WHIP_WPMessageDismissListener::listen() method does have tests, but mocks away the Whip_MessageDismisser::verifyNonce() method, so the mock was hiding the bug.

/cc @vraja-pro

The `Whip_MessageDismisser::verifyNonce()` method expects to be passed a `string`, but if the nonce was not available, it would be passed `null`, which could lead to PHP 8.1 "passing null to non-nullable" deprecation notices (though in this case wouldn't as the underlying [`wp_verify_nonce()`](https://developer.wordpress.org/reference/functions/wp_verify_nonce/) function casts the value to string anyway).

All the same, it is a bug. Fixed now.

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

The `WHIP_WPMessageDismissListener::listen()` method does have tests, but mocks away the `Whip_MessageDismisser::verifyNonce()` method, so the mock was hiding the bug.
@jrfnl jrfnl added this to the 1.x Next Release milestone Sep 26, 2023
@coveralls
Copy link

Pull Request Test Coverage Report for Build 6312604562

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 27.5%

Totals Coverage Status
Change from base Build 6312330475: 0.0%
Covered Lines: 66
Relevant Lines: 240

💛 - Coveralls

@jrfnl jrfnl merged commit 9efacd2 into main Sep 26, 2023
17 checks passed
@jrfnl jrfnl deleted the JRF/whip_wpmessagedismisslisterner-bug-fix branch September 26, 2023 12:28
@enricobattocchi enricobattocchi modified the milestones: 1.x Next Release, 2.0 Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants