[wp-trac] [WordPress Trac] #62824: single_month_title() can cause a warning.
WordPress Trac
noreply at wordpress.org
Sun Jan 19 14:18:49 UTC 2025
#62824: single_month_title() can cause a warning.
--------------------------+-----------------------------
Reporter: apermo | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version: 2.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
In my sentry setup I got this error message over the weekend.
`Warning: Undefined array key "00"` caused by `single_month_title()`
This is the relevante piece of code.
{{{#!php
<?php
$m = get_query_var( 'm' );
// ...
} elseif ( ! empty( $m ) ) {
$my_year = substr( $m, 0, 4 );
$my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
}
}}}
This assumes that `get_query_var( 'm' )` is always at least 6 digits, and
always contains the year and the month.
But comparing to https://core.trac.wordpress.org/browser/tags/6.7/src/wp-
includes/class-wp-query.php#L2048, this shows that this is not necessarily
true.
I think that the most robust solution would be to add a sanitization to
`$wp_locale->get_month()`.
I will open a PR for that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62824>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list