WordPress.org

Making WordPress.org

Opened 5 years ago

Closed 5 years ago

#932 closed defect (invalid)

wp_title if archive of year w/o permalink fires php notice in locale.php

Reported by: michelwppi Owned by:
Milestone: Priority: normal
Component: General Keywords:
Cc:

Description

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.

Change History (2)

#1 @michelwppi
5 years ago

  • Cc contact@… added

#2 @ocean90
5 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Hello michelwppi,

this trac is for reporting bugs around the wordpress.org site, not WordPress itself. Please use https://core.trac.wordpress.org.

Note: See TracTickets for help on using tickets.