From 330f070340c896b6df45156301fe4ba9b7ce85fb Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 10 Oct 2023 11:22:24 +0000 Subject: [PATCH] Query: Ensure that the `page` parameter is scalar in `WP_Query::get_posts()`. The `page` query var only accepts a scalar value and passes the value through functions that assume a scalar value. Adding an extra guard condition does not affect its functionality but does avoid a PHP fatal error for `trim()` when a non-scalar value such as an array is passed. Follow-up to [2535], [53891]. Props brookedot, rlmc, mukesh27, SergeyBiryukov. Fixes #56558. Built from https://develop.svn.wordpress.org/trunk@56815 git-svn-id: http://core.svn.wordpress.org/trunk@56327 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-query.php | 3 +-- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php index 3fcb942aa7..e79f460fc5 100644 --- a/wp-includes/class-wp-query.php +++ b/wp-includes/class-wp-query.php @@ -2020,8 +2020,7 @@ class WP_Query { } if ( isset( $q['page'] ) ) { - $q['page'] = trim( $q['page'], '/' ); - $q['page'] = absint( $q['page'] ); + $q['page'] = is_scalar( $q['page'] ) ? absint( trim( $q['page'], '/' ) ) : 0; } // If true, forcibly turns off SQL_CALC_FOUND_ROWS even when limits are present. diff --git a/wp-includes/version.php b/wp-includes/version.php index b2ac7a3bdf..ac5beebc97 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-beta2-56814'; +$wp_version = '6.4-beta2-56815'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.