Jetpack uses a clean_nonces function to regularly remove nonces created when communicating with WordPress.com.
However, when you use Development Mode, you don't actually need to clean nonces. We should make sure we only run this when necessary.
Reported here:
https://wordpress.org/support/topic/we-run-jetpack_dev_debug-do-we-need-to-run-the-jetpack_clean_nonces-hook/
I'm giving this a try. Would it be right to solve this by something like this? -
if ( ! Jetpack::is_development_mode() ) {
add_action( 'jetpack_clean_nonces', array( $this, 'clean_nonces' ) );
}
This change would be made in - https://github.com/Automattic/jetpack/blob/a8e73e10d3bfb83ef0274f22b7dc5b59ac0db6c2/packages/connection/src/Manager.php
@jeherve any advice? :)
That sounds good to me 馃憤
Thanks Jer. Added a PR above ^
I have a counterargument :)
It seems to me dev mode should be as similar as possible to production mode.
Suppose a developer wants to work on/debug/improve/whatever this nonce cleaning. If we turned off nonce cleaning in dev mode, this hypothetical developer would have to do their work on a connected site. Do we want to force them to do that, or do we want to allow them to do as much as they can in dev mode?
Similarly, suppose some production site is having problems. A developer spins up a "staging"/local site to debug those problems. Seeing those wp-cron tasks and related queries (even though they do nothing on a non-connected site), might be valuable to that developer debugging whatever the problem is.
Note that the original reporter mentioned that the jetpack_clean_nonces wp-cron task was running on every wp-cron run, not just hourly. If that's the case in dev mode or when connected (or when not yet connected but not in dev mode), we should fix that regardless of what we decide to do about nonce cleaning in dev mode.
Hearing the arguments, I concur that we should try to keep the code path as similar in dev/prod as possible except where there is a functional need (e.g. the function requires a WP.com API call). I'm going to close this as a wontfix, though noting in appreciation @omkarbhagat93's work to resolve it.
Most helpful comment
I have a counterargument :)
It seems to me dev mode should be as similar as possible to production mode.
Suppose a developer wants to work on/debug/improve/whatever this nonce cleaning. If we turned off nonce cleaning in dev mode, this hypothetical developer would have to do their work on a connected site. Do we want to force them to do that, or do we want to allow them to do as much as they can in dev mode?
Similarly, suppose some production site is having problems. A developer spins up a "staging"/local site to debug those problems. Seeing those wp-cron tasks and related queries (even though they do nothing on a non-connected site), might be valuable to that developer debugging whatever the problem is.
Note that the original reporter mentioned that the
jetpack_clean_nonceswp-cron task was running on every wp-cron run, not just hourly. If that's the case in dev mode or when connected (or when not yet connected but not in dev mode), we should fix that regardless of what we decide to do about nonce cleaning in dev mode.