Skip to content

Conversation

@koen12344
Copy link
Contributor

Fixes #126 and #127

Copy link
Member

@ianmjones ianmjones left a 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 ) . '%';
Copy link
Member

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

Copy link
Contributor Author

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,
Copy link
Member

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?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Batches (potentially) not running in context of site that created them in multisite

2 participants