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

Prevent saving unnecessary Jetpack post_by_email_address* DB options #5311

Merged
merged 6 commits into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions vip-jetpack/vip-jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,27 @@ function vip_filter_jetpack_offline_mode_on_site_launch( $offline_mode ) {
}

add_filter( 'jetpack_offline_mode', 'vip_filter_jetpack_offline_mode_on_site_launch', PHP_INT_MAX, 1 );

/**
* Prevent admin/support users from spawning (useless, autoloaded) NULL value post_by_email_address* options.
* Addresses https://github.com/Automattic/jetpack/issues/35636
*/
function vip_prevent_jetpack_post_by_email_database_noise() {
// Prevent saving an unnecessary NULL option to the database.
add_filter( 'pre_update_option_post_by_email_address' . get_current_user_id(), function ( $value, $old_value ) {
if ( 'NULL' === $value ) {
return $old_value;
}

return $value;
}, 10, 2 );

// Prevent unnecessary API calls for finding the remote email address when the module is disabled.
if ( method_exists( 'Jetpack', 'is_module_active' ) && ! Jetpack::is_module_active( 'post-by-email' ) ) {
add_filter( 'pre_option_post_by_email_address' . get_current_user_id(), function () {
return 'NULL';
} );
}
}

add_action( 'admin_init', 'vip_prevent_jetpack_post_by_email_database_noise' );
Loading