From b742570d1b62753a4b7d6f7cc164e403b8a4d3b2 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Wed, 15 Jan 2025 18:36:24 +0000 Subject: [PATCH] REST API: Fix PHP warning about undefined `paged` argument in various REST API endpoints. This bug could occur in `WP_REST_Posts_Controller`, `WP_REST_Global_Styles_Revisions_Controller`, `WP_REST_Revisions_Controller`, and any of their child classes. This changeset fixes it throughout. Props apermo, pbearne, hemant-ahir, flixos90. Fixes #62292. Built from https://develop.svn.wordpress.org/trunk@59630 git-svn-id: http://core.svn.wordpress.org/trunk@58993 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../class-wp-rest-global-styles-revisions-controller.php | 2 +- .../rest-api/endpoints/class-wp-rest-posts-controller.php | 2 +- .../rest-api/endpoints/class-wp-rest-revisions-controller.php | 2 +- wp-includes/version.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php index 54285fa560..4108f9711c 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php @@ -189,7 +189,7 @@ class WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Revisions_Contr $revisions_query = new WP_Query(); $revisions = $revisions_query->query( $query_args ); $offset = isset( $query_args['offset'] ) ? (int) $query_args['offset'] : 0; - $page = (int) $query_args['paged']; + $page = isset( $query_args['paged'] ) ? (int) $query_args['paged'] : 0; $total_revisions = $revisions_query->found_posts; if ( $total_revisions < 1 ) { diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 95851199c6..6f872be3df 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -457,7 +457,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { remove_filter( 'post_password_required', array( $this, 'check_password_required' ) ); } - $page = (int) $query_args['paged']; + $page = isset( $query_args['paged'] ) ? (int) $query_args['paged'] : 0; $total_posts = $posts_query->found_posts; if ( $total_posts < 1 && $page > 1 ) { diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php index fb5fa29231..1dbc611631 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php @@ -294,7 +294,7 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { $revisions_query = new WP_Query(); $revisions = $revisions_query->query( $query_args ); $offset = isset( $query_args['offset'] ) ? (int) $query_args['offset'] : 0; - $page = (int) $query_args['paged']; + $page = isset( $query_args['paged'] ) ? (int) $query_args['paged'] : 0; $total_revisions = $revisions_query->found_posts; if ( $total_revisions < 1 ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 60b7925b64..88503aa99d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59607'; +$wp_version = '6.8-alpha-59630'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.