From 365645c608586b6e0871187d12eafeeb076c633d Mon Sep 17 00:00:00 2001 From: audrasjb Date: Tue, 25 Feb 2025 22:40:22 +0000 Subject: [PATCH] Date/Time: Add sanitization to `WP_Locale::get_month()`. By adding a sanitization to `$wp_locale->get_month()`, this changeset prevents a PHP Warning: `Undefined array key "00"` caused by `single_month_title()`. This function previously assumed that `get_query_var( 'm' )` is always at least 6 digits, and always contains the year and the month, which is not necessarily true. Props apermo, audrasjb, xateman. Fixes #62824. Built from https://develop.svn.wordpress.org/trunk@59870 git-svn-id: http://core.svn.wordpress.org/trunk@59212 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-locale.php | 8 ++++++-- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-locale.php b/wp-includes/class-wp-locale.php index a78617b5e3..0fcb130b81 100644 --- a/wp-includes/class-wp-locale.php +++ b/wp-includes/class-wp-locale.php @@ -315,10 +315,14 @@ class WP_Locale { * @since 2.1.0 * * @param string|int $month_number '01' through '12'. - * @return string Translated full month name. + * @return string Translated full month name. If the month number is not found, an empty string is returned. */ public function get_month( $month_number ) { - return $this->month[ zeroise( $month_number, 2 ) ]; + $month_number = zeroise( $month_number, 2 ); + if ( ! isset( $this->month[ $month_number ] ) ) { + return ''; + } + return $this->month[ $month_number ]; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index e218ba53a2..1c53a575df 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59869'; +$wp_version = '6.8-alpha-59870'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.