Sync Checksums: Refactor checksum logic to allow 'jetpack_sync_checksum_allowed_tables' filter to work with audits #40307
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The purpose of this PR is to refactor the Checksum Audit functionality,
Replicastore::checksum_all
to allow dynamic support for additional checksums and provide a single source of truth for the supported ones.So far, we were manually creating audit checksums for default Sync modules (tables), like eg
posts
andcomments
and explicitly checking thejetpack_table_checksum_force_enable_*
filters we knew about, eg forwoocommerce
andwoocommerce_hpos_orders
modules.However, this approach will not work if Sync package consumers want to add their own custom table support for checksums. Here's an example PR for the WooCommerce Analytics plugin.
Therefore, we are refactoring
Replicastore::checksum_all
to fetch all the supported ones dynamically by:Table_Checksum::get_allowed_tables
: A public static method that uses thejetpack_sync_checksum_allowed_tables
filter under the hood, so that the allowed checksum tables become available to all consumersReplicastore::checksum_all
to fetch the allowed tables and iterate on those instead of hardcoding the tablesThis way if a consumer adds checksum support for an additional custom table via the
jetpack_sync_checksum_allowed_tables
filter, Audit Checksums will take that table into account to both on remote sites and WPCOM.Proposed changes:
Automattic\Jetpack\Sync\Replicastore\Table_Checksum
: Introduce public staticget_allowed_tables
for fetching the allowed checksum tables via thejetpack_sync_checksum_allowed_tables
filter.Automattic\Jetpack\Sync\Replicastore
: Refactorchecksum_all
to rely onTable_Checksum::get_allowed_tables
for fetching the allowed checksum tablesOther information:
Jetpack product discussion
pfKYZu-1Po-p2
Does this pull request change what data or activity we track or use?
No
Testing instructions: