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
This commit is contained in:
audrasjb
2025-02-25 22:40:22 +00:00
parent f35df6f37a
commit 365645c608
2 changed files with 7 additions and 3 deletions

View File

@@ -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 ];
}
/**

View File

@@ -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.