Skip to content

Commit 12eaef1

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@59870 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0735741 commit 12eaef1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/wp-includes/class-wp-locale.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,14 @@ public function get_weekday_abbrev( $weekday_name ) {
315315
* @since 2.1.0
316316
*
317317
* @param string|int $month_number '01' through '12'.
318-
* @return string Translated full month name.
318+
* @return string Translated full month name. If the month number is not found, an empty string is returned.
319319
*/
320320
public function get_month( $month_number ) {
321-
return $this->month[ zeroise( $month_number, 2 ) ];
321+
$month_number = zeroise( $month_number, 2 );
322+
if ( ! isset( $this->month[ $month_number ] ) ) {
323+
return '';
324+
}
325+
return $this->month[ $month_number ];
322326
}
323327

324328
/**

0 commit comments

Comments
 (0)