Commit 3d1a01d3 authored by Erick Hitter's avatar Erick Hitter
Browse files

Fix two pagination bugs that led to excessive queries

Looped until circuit breaker tripped because `$page` wasn't respected. Also revealed that an additional query was run when we knew it wasn't needed, because we got back fewer entries than we asked for.
parent c221bd04
......@@ -138,13 +138,14 @@ class Events_Store extends Singleton {
);
// Get events to re-render as the cron option
$page = 1;
$page = 1;
$quantity = 100;
do {
$jobs_posts = $this->get_jobs( array(
'status' => self::STATUS_PENDING,
'quantity' => 100,
'page' => 1,
'quantity' => $quantity,
'page' => $page,
) );
// Nothing more to add
......@@ -186,7 +187,11 @@ class Events_Store extends Singleton {
if ( isset( $jobs_post->interval ) ) {
$cron_array[ $timestamp ][ $action ][ $instance ]['interval'] = $jobs_post->interval;
}
}
// No need to keep looping if there were fewer events than we asked for
if ( count( $jobs_posts ) < $quantity ) {
break;
}
}
} while( true );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment