-
Notifications
You must be signed in to change notification settings - Fork 171
Run batches in multisite within context of site that created them #128
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
base: master
Are you sure you want to change the base?
Conversation
ianmjones
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.
Thanks for this @koen12344.
We'll have to give this a test and decide whether it's the way we'd like to tackle the problem, and consider whether it'll affect any current users.
In the meantime, I spotted a couple of potential issues that I thought I'd best bring to your attention in the code comments.
|
|
||
| $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; | ||
| if( !is_null( $for_site_id ) ) { | ||
| $key = $wpdb->esc_like( $this->identifier . '_batch_' . $for_site_id ) . '%'; |
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.
I think you probably need '_%' rather than '%' at the end here, otherwise you may be selecting for all subsites whose ID begins with the required ID, and any batch without a subsite ID that happens to have a generated key that begins with the subsite ID.
e.g. for subsite ID = 1, the following are going to match:
wibble_batch_1_1abcde <-- GOOD
wibble_batch_10_1abcde <-- BAD
wibble_batch_11_1abcde <-- BAD
wibble_batch_101_1abcde <-- BAD
wibble_batch_1abcde <-- BAD
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.
Good catch, I think you might be right about that.
| */ | ||
| $throttle_seconds = max( | ||
| 0, | ||
| $this->seconds_between_batches, |
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.
I think you probably meant for this change to apply to the value passed into the inner apply_filters?
|
I don't think this PR is necessary. We do this in our code to be multisite compatible |
Fixes #126 and #127