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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a filter to prevent async post status event from being scheduled #964

Merged
merged 1 commit into from Sep 5, 2018

Conversation

Projects
None yet
2 participants
@CodeProKid
Contributor

CodeProKid commented Sep 5, 2018

Description

We have been having some issues with too many cron events being scheduled with posts getting published. This is happening because we use custom post types as a storage mechanism for various things that don't contain any public information.

To prevent this from happening I've added a filter here where we can conditionally set the value to false and it will prevent the cron event from being scheduled.

For our implementation, we plan on doing something like:

add_filter( 'wpcom_async_transition_post_status_schedule_async', function( $value, $args ) {
    if ( 'my-post-type' === get_post_type( $args['post_id'] ) ) {
        $value = false;
    }
    return $value;
}, 10, 2 );

Checklist

Please make sure the items below have been covered before requesting a review:

  • This change works and has been tested locally (or has an appropriate fallback).
  • This change works and has been tested on a Go sandbox.
  • This change has relevant unit tests (if applicable).
  • This change has relevant documentation additions / updates (if applicable).

Steps to Test

  1. Check out PR.
  2. Add the above code (replacing CPT name with page)
  3. Publish a new page
  4. No event shout have gotten scheduled
  5. 馃挵
@mjangda

mjangda approved these changes Sep 5, 2018

Looks good; thanks!

@mjangda mjangda merged commit f760fe7 into Automattic:master Sep 5, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@mjangda

This comment has been minimized.

Member

mjangda commented Sep 5, 2018

Deployed (r117707-deploy)

@mjangda mjangda referenced this pull request Sep 5, 2018

Merged

Bump concurrency of the transition events #966

3 of 4 tasks complete
@mjangda

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment