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

Conflict when dispatching batch from Ajax call #129

Open
koen12344 opened this issue Jan 11, 2025 · 3 comments · May be fixed by #130
Open

Conflict when dispatching batch from Ajax call #129

koen12344 opened this issue Jan 11, 2025 · 3 comments · May be fixed by #130

Comments

@koen12344
Copy link

The library checks the nonce arg in the get_chain_id() function when calling dispatch(). That arg is potentially overwritten by plugins, causing the nonce validation to fail, and the request to 403. The process will then not be dispatched and no healthcheck will be scheduled.

@koen12344
Copy link
Author

Actually, diving deeper into the code, I think the issue is simply trying to dispatch a batch from any Ajax call. This will make the if ( empty( $this->chain_id ) && wp_doing_ajax() ) { line in get_chain_id() return true, and make it look for a nonce arg that isn't set, or doesn't apply to the library

koen12344 added a commit to koen12344/multisite-background-processing that referenced this issue Jan 11, 2025
@craigrileyuk
Copy link

Having this issue too. It's breaking the WooCommerce checkout since I'm using a queue to dispatch emails to a custom mail server.

Fix would be much appreciated.

@koen12344 koen12344 changed the title Consider prefixing nonce arg to avoid conflicts Conflict when dispatching batch from Ajax call Jan 29, 2025
@koen12344
Copy link
Author

koen12344 commented Jan 29, 2025

@craigrileyuk You can temporarily use my fixed branch by including the repo in your composer.json:

"repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/koen12344/multisite-background-processing"
    }
  ],
"deliciousbrains/wp-background-processing": "dev-prod",

It fixes this issue, as well as the other issue I opened with processing batches on multisite. I use it in production on a few plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants