From 51346d566a40e41fba54136405ce816f00a7ce29 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Sun, 7 Aug 2022 23:05:10 +0000 Subject: [PATCH] Rewrite rules: Prevent malformed date requests throwing notices. Ensure that date queries contain each component before attempting to use them. This prevents http requests triggering notices if a portion of the date is missing. For example a request containing a day and year but no month, a request containing a month bu not year. Props ovidiul, dd32, peterwilsoncc, costdev, johnbillion, SergeyBiryukov, desrosj, tremidkhar, hellofromTonya. Fixes #52252. Built from https://develop.svn.wordpress.org/trunk@53857 git-svn-id: http://core.svn.wordpress.org/trunk@53416 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rewrite.php | 5 ++++- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index ab23a1887c..af66d02b94 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -410,7 +410,10 @@ function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) { } // This is the potentially clashing slug. - $value = $query_vars[ $compare ]; + $value = ''; + if ( $compare && array_key_exists( $compare, $query_vars ) ) { + $value = $query_vars[ $compare ]; + } $post = get_page_by_path( $value, OBJECT, 'post' ); if ( ! ( $post instanceof WP_Post ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 4587006415..8ac87d7b55 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53856'; +$wp_version = '6.1-alpha-53857'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.