[wp-meta] [Making WordPress.org] #932: wp_title if archive of year w/o permalink fires php notice in locale.php
Making WordPress.org
noreply at wordpress.org
Wed Mar 4 10:06:49 UTC 2015
#932: wp_title if archive of year w/o permalink fires php notice in locale.php
-----------------------+---------------------
Reporter: michelwppi | Owner:
Type: defect | Status: new
Priority: normal | Component: General
Keywords: |
-----------------------+---------------------
PHP Notice : Undefined index: 00 in /Applications/MAMP/htdocs/wp_svn41/wp-
includes/locale.php on line 271
The concerned function : $wp_locale->get_month
Permalinks = default like: www.mysite.com/?m=2015
The calling function = wp_title in general-template.php
Here:
{{{
// If there's a month
if ( is_archive() && !empty($m) ) {
$my_year = substr($m, 0, 4);
$my_month = $wp_locale->get_month(substr($m, 4, 2));
error_log("toto");
$my_day = intval(substr($m, 6, 2));
$title = $my_year . ( $my_month ? $t_sep . $my_month : ''
) . ( $my_day ? $t_sep . $my_day : '' );
}
}}}
This part of function forget that 'm' query_tag can have a length from 4
to 9+ as well defined in query.php - not only month...
and $wp_locale->get_month do not like empty string giving '00' index...
{{{
if ( $qv['m'] ) {
$this->is_date = true;
if ( strlen($qv['m']) > 9 ) {
$this->is_time = true;
} else if ( strlen($qv['m']) > 7 ) {
$this->is_day = true;
} else if ( strlen($qv['m']) > 5 ) {
$this->is_month = true;
} else {
$this->is_year = true;
}
}
}}}
Suggestion (raw):
Add test ( strlen($m) >= 5 ) before to call $wp_locale->get_month
like
{{{
$my_month = ( strlen($m) >= 5 ) ? $wp_locale->get_month(substr($m, 4, 2))
: "";
}}}
Cheers,
M.
--
Ticket URL: <https://meta.trac.wordpress.org/ticket/932>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org
More information about the wp-meta
mailing list