-
Notifications
You must be signed in to change notification settings - Fork 846
Sync: add Action Scheduler to the list of blacklisted post types #12830
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
Conversation
|
re running tests |
This is an automated check which relies on |
timmyc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeherve thanks for running with the fix here. So looks like this is working somewhat - I'm not seeing the posts synched anymore in the activity log, but I am seeing comments on the Action Scheduler post showing up in Calypso:
I ran this test by creating a new jurassic.ninja instance with this branch... so I think I did it right, but just in case here is my plugin setup on the site:
Jetpack Free plan.
Wondering if we could also filter these off in the calypso view too. That would effectively hide all past actions too. I could look into that if that would help.
|
So did some looking to see if there was a clean way to filter off these events in Calypso. While we could add in some checks there in the components to see if the log events are related to ActionScheduler, and then not display them, that will obviously making pagination wonky in the UI. Next stop was the endpoint logic I suppose some logic could be added to the endpoint itself to filter off activity log results prior to sending the API response. I didn't dig further but that seems do-able. But ultimately looks like using this filter should allow preventing a sync of a comment made by ActionScheduler and clear up the Activity log on wpcom completely. I think I may have mentioned this already, but the plan is for ActionScheduler to move away from being a CPT ( /cc @rrennick ) in the next major release of 3.0. So really this problem is kind of a temporary issue until that happens. Going to comment on the original issue to that affect to. I guess my .02 - this has been reported as a bug by one person. We do have a way to fix this it seems, but if we do we should also circle back and clean this code up once a CPT is no longer used. |
Migrating off the CPT will depend on the site running PHP 5.6 or higher. So, this could be coordinated with when JP also requires 5.6. |
Ah, that's a good point. I like the idea of filtering off comments belonging to a specific post type, or comments of a specific comment type. @lezama What's your take on this?
That sounds like a good idea. Jetpack aims to support the last 2 versions of WordPress, and match their requirements. That means that when WordPress 5.3 is released, we'll support WP 5.3 and WP 5.2, and our PHP requirements will then match WP 5.2 (PHP 5.6). |
that should do it yes 👍 Are these actions completely useless in order to debug what's going on on the site? shouldn't these leave Rewind "checkpoints"? |
ActionScheduler jobs can do any variety of logic behind the scenes. So theoretically I could see someone wanting to rewind to a point in time before a specific job executed. But it seems like the actions spawned by the jobs ( updating a post, product inventory whatever it might be ) will also create a new restore point/action that could be restored against too.... so kind of redundant. |
|
@lezama Would something like this work, or should this live within diff --git a/packages/sync/src/modules/WooCommerce.php b/packages/sync/src/modules/WooCommerce.php
index 84d77a037..f4b5a9f2d 100644
--- a/packages/sync/src/modules/WooCommerce.php
+++ b/packages/sync/src/modules/WooCommerce.php
@@ -48,6 +48,9 @@ class WooCommerce extends Module {
add_filter( 'jetpack_sync_before_enqueue_woocommerce_new_order_item', array( $this, 'filter_order_item' ) );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_update_order_item', array( $this, 'filter_order_item' ) );
+
+ // Blacklist Action Scheduler comment types.
+ add_filter( 'jetpack_sync_prevent_sending_comment_data', array( $this, 'filter_action_scheduler_comments' ), 10, 2 );
}
function name() {
@@ -168,6 +171,24 @@ class WooCommerce extends Module {
return array_merge( $list, self::$wc_comment_meta_whitelist );
}
+ /**
+ * Stop comments from the Action Scheduler from being synced.
+ * https://github.com/woocommerce/woocommerce/tree/e7762627c37ec1f7590e6cac4218ba0c6a20024d/includes/libraries/action-scheduler
+ *
+ * @since 7.6.0
+ *
+ * @param boolean $can_sync Should we prevent comment data from bing synced to WordPress.com.
+ * @param mixed $comment WP_COMMENT object.
+ *
+ * @return bool
+ */
+ public function filter_action_scheduler_comments( $can_sync, $comment ) {
+ if ( isset( $comment->comment_agent ) && 'ActionScheduler' === $comment->comment_agent ) {
+ return true;
+ }
+ return $can_sync;
+ }
+
private static $wc_options_whitelist = array(
'woocommerce_currency',
'woocommerce_db_version',
|
|
@jeherve perfect, I think it needs to go in the woo module 👍 |
5863ab2 to
1000004
Compare
Fixes #12714 Those events do not need to be synced with WordPress.com.
a7db6af to
f481a2b
Compare
* Add initial changelog / testing list changes for 7.6 * Update stable tag to 7.5.3 * changelog: add #12957 * Changelog: add #12932 * Changelog: add #12867 * Changelog: add #12823 * changelog: add #12969 * changelog: add #13012 * changelog: add #12974 * Changelog: add #13059 * Changelog: add #13079 * Changelog: add #12924 * changelog: add #12954 * Changelog: add #12959 * Changelog: add #12977 * Changelog: add #12830 * Changelog: add #12926 * Changelog: add #12958 * Changelog: add #12999 * Changelog: add #13077 * Changelog: add #13083 * Changelog: add #13087 * Changelog: add #13110 * Changelog: add #13116 * Changelog: add #13117 * Changelog: add #12821 * Changelog: add #13120 * changelog: add #13139 * Changelog: add #13143 * Changelog: add #13147 * Testing list: add section about sync
* Add initial changelog / testing list changes for 7.6 * Update stable tag to 7.5.3 * changelog: add #12957 * Changelog: add #12932 * Changelog: add #12867 * Changelog: add #12823 * changelog: add #12969 * changelog: add #13012 * changelog: add #12974 * Changelog: add #13059 * Changelog: add #13079 * Changelog: add #12924 * changelog: add #12954 * Changelog: add #12959 * Changelog: add #12977 * Changelog: add #12830 * Changelog: add #12926 * Changelog: add #12958 * Changelog: add #12999 * Changelog: add #13077 * Changelog: add #13083 * Changelog: add #13087 * Changelog: add #13110 * Changelog: add #13116 * Changelog: add #13117 * Changelog: add #12821 * Changelog: add #13120 * changelog: add #13139 * Changelog: add #13143 * Changelog: add #13147 * Testing list: add section about sync


Fixes #12714
Changes proposed in this Pull Request:
The data is currently stored in a custom post type, and as such it appears in WordPress.com' activity log even though it does not provide a lot of value to site owners:
This PR stops this post type from being synchronized with WordPress.com, so the events should then stop appearing in the activity log.
Edit
I've now removed the additonal blacklisting of the Action Scheduler comments, as those will not be synced once #13079 gets merged.
Testing instructions:
ActionSchedulerin your activity log.Proposed changelog entry for your changes: