From 996119820992138fc29fda2e76abdbe81626a3f9 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 30 Apr 2024 09:14:51 -0700 Subject: [PATCH] Use posts member of WP_Query instead of get_posts method --- bin/add-test-widgets-to-sidebar.php | 2 +- bin/create-embed-test-post.php | 2 +- includes/validation/class-amp-validated-url-post-type.php | 4 ++-- src/Support/SupportData.php | 2 +- src/Validation/ScannableURLProvider.php | 4 ++-- tests/php/src/Validation/ScannableURLProviderTest.php | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/add-test-widgets-to-sidebar.php b/bin/add-test-widgets-to-sidebar.php index 68580abc2ca..915852b712a 100644 --- a/bin/add-test-widgets-to-sidebar.php +++ b/bin/add-test-widgets-to-sidebar.php @@ -294,7 +294,7 @@ function amp_media( $type, $count = 3 ) { ) ); } - return $query->get_posts(); + return $query->posts; } /** diff --git a/bin/create-embed-test-post.php b/bin/create-embed-test-post.php index 8ac04574de2..d4388b93960 100644 --- a/bin/create-embed-test-post.php +++ b/bin/create-embed-test-post.php @@ -242,7 +242,7 @@ function amp_get_media_items_ids( $type, $image_count = 3 ) { ) ); } - return implode( ',', $query->get_posts() ); + return implode( ',', $query->posts ); } /** diff --git a/includes/validation/class-amp-validated-url-post-type.php b/includes/validation/class-amp-validated-url-post-type.php index d644bf29c93..3b16fb84565 100644 --- a/includes/validation/class-amp-validated-url-post-type.php +++ b/includes/validation/class-amp-validated-url-post-type.php @@ -994,7 +994,7 @@ public static function delete_stylesheets_postmeta_batch( $count, $before ) { 'posts_per_page' => $count, ] ); - foreach ( $query->get_posts() as $post_id ) { + foreach ( $query->posts as $post_id ) { if ( delete_post_meta( $post_id, self::STYLESHEETS_POST_META_KEY ) ) { $deleted++; } @@ -1037,7 +1037,7 @@ public static function garbage_collect_validated_urls( $count = 100, $before = ' ], ] ); - foreach ( $query->get_posts() as $post ) { + foreach ( $query->posts as $post ) { if ( ! self::is_post_safe_to_garbage_collect( $post ) ) { continue; } diff --git a/src/Support/SupportData.php b/src/Support/SupportData.php index fa06b0263c3..dd288df26b0 100644 --- a/src/Support/SupportData.php +++ b/src/Support/SupportData.php @@ -679,7 +679,7 @@ public function get_amp_urls() { ]; $query = new WP_Query( $query_args ); - $amp_validated_posts = $query->get_posts(); + $amp_validated_posts = $query->posts; foreach ( $amp_validated_posts as $amp_validated_post ) { $validation_data = $this->process_raw_post_errors( $amp_validated_post ); diff --git a/src/Validation/ScannableURLProvider.php b/src/Validation/ScannableURLProvider.php index d3937b646b0..24f2a1efff4 100644 --- a/src/Validation/ScannableURLProvider.php +++ b/src/Validation/ScannableURLProvider.php @@ -336,7 +336,7 @@ private function get_author_page_urls( $offset, $number ) { 'posts_per_page' => 1, ] ); - if ( count( $authored_post_query->get_posts() ) > 0 ) { + if ( count( $authored_post_query->posts ) > 0 ) { $author_page_urls[] = get_author_posts_url( $author->ID, $author->user_nicename ); } } @@ -376,7 +376,7 @@ private function get_date_page() { 'order' => 'DESC', ] ); - $posts = $query->get_posts(); + $posts = $query->posts; $latest_post = array_shift( $posts ); if ( ! $latest_post ) { diff --git a/tests/php/src/Validation/ScannableURLProviderTest.php b/tests/php/src/Validation/ScannableURLProviderTest.php index c5eadafc04a..c8713745b12 100644 --- a/tests/php/src/Validation/ScannableURLProviderTest.php +++ b/tests/php/src/Validation/ScannableURLProviderTest.php @@ -517,7 +517,7 @@ public function test_get_date_page() { 'fields' => 'ids', ] ); - foreach ( $query->get_posts() as $deleted_post ) { + foreach ( $query->posts as $deleted_post ) { wp_delete_post( $deleted_post ); } $this->assertNull( $this->call_private_method( $this->scannable_url_provider, 'get_date_page' ) );