From ad2518dbd3d4a63f38414aec4e4b92c9933a3913 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 18 Mar 2022 09:02:31 -0300 Subject: [PATCH 1/2] Only use advanced pagination for supported indexables --- includes/classes/IndexHelper.php | 2 +- includes/classes/Indexable.php | 9 +++++++++ includes/classes/Indexable/Post/Post.php | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/includes/classes/IndexHelper.php b/includes/classes/IndexHelper.php index 3421c97366..e56bdd2d95 100644 --- a/includes/classes/IndexHelper.php +++ b/includes/classes/IndexHelper.php @@ -482,7 +482,7 @@ protected function get_objects_to_index() { 'per_page' => absint( $per_page ), ]; - if ( 'offset' === $this->index_meta['pagination_method'] ) { + if ( ! $indexable->support_indexing_advanced_pagination || 'offset' === $this->index_meta['pagination_method'] ) { $args['offset'] = $this->index_meta['offset']; } diff --git a/includes/classes/Indexable.php b/includes/classes/Indexable.php index 62c03e00c6..5b9d7514e4 100644 --- a/includes/classes/Indexable.php +++ b/includes/classes/Indexable.php @@ -54,6 +54,15 @@ abstract class Indexable { */ public $query_integration; + /** + * Flag to indicate if the indexable has support for + * `id_range` pagination method during a sync. + * + * @var boolean + * @since 4.0.2 + */ + public $support_indexing_advanced_pagination = false; + /** * Get number of bulk items to index per page * diff --git a/includes/classes/Indexable/Post/Post.php b/includes/classes/Indexable/Post/Post.php index e8344ea8c8..1d3f881825 100644 --- a/includes/classes/Indexable/Post/Post.php +++ b/includes/classes/Indexable/Post/Post.php @@ -32,6 +32,15 @@ class Post extends Indexable { */ public $slug = 'post'; + /** + * Flag to indicate if the indexable has support for + * `id_range` pagination method during a sync. + * + * @var boolean + * @since 4.0.2 + */ + public $support_indexing_advanced_pagination = true; + /** * Create indexable and initialize dependencies * From 64457360c563f8fb40e4cff34c3f1d23965eebb8 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Mon, 28 Mar 2022 15:15:50 -0300 Subject: [PATCH 2/2] Adjust `@since` tags --- includes/classes/Indexable.php | 2 +- includes/classes/Indexable/Post/Post.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/classes/Indexable.php b/includes/classes/Indexable.php index adb07f95fd..3f9f882322 100644 --- a/includes/classes/Indexable.php +++ b/includes/classes/Indexable.php @@ -59,7 +59,7 @@ abstract class Indexable { * `id_range` pagination method during a sync. * * @var boolean - * @since 4.0.2 + * @since 4.1.0 */ public $support_indexing_advanced_pagination = false; diff --git a/includes/classes/Indexable/Post/Post.php b/includes/classes/Indexable/Post/Post.php index 78a04c0f5b..64b60fb856 100644 --- a/includes/classes/Indexable/Post/Post.php +++ b/includes/classes/Indexable/Post/Post.php @@ -37,7 +37,7 @@ class Post extends Indexable { * `id_range` pagination method during a sync. * * @var boolean - * @since 4.0.2 + * @since 4.1.0 */ public $support_indexing_advanced_pagination = true;