[wp-trac] [WordPress Trac] #31521: wp_title if archive of year w/o permalink fires php notice in locale.php

WordPress Trac noreply at wordpress.org
Wed Mar 4 10:28:49 UTC 2015


#31521: wp_title if archive of year w/o permalink fires php notice in locale.php
--------------------------+-----------------------------
 Reporter:  michelwppi    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.1.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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("here calling...");
                 $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...


 {{{
 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;
                                 }
                         }
 }}}

 and $wp_locale->get_month do not like empty string giving '00' index...

 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://core.trac.wordpress.org/ticket/31521>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list