Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#9336 closed task (blessed) (fixed)

E_NOTICE undefined offset in wp-includes/theme.php

Reported by: Mittineague Owned by:
Milestone: 2.8 Priority: lowest
Severity: trivial Version: 2.7.1
Component: Themes Keywords: has-patch theme
Focuses: Cc:


With my Error Reporting plugin I get

E_NOTICE Undefined offset: 1 at /home/mittineague/mittineague.com/blog/wp-includes/theme.php (212) timed at 15-Mar-2009 01:53:41

eg. (several similar lines)

{{{if ( preg_match( '|Author URI:(.*)$|mi', $theme_data, $author_uri ) )

$author_uri = clean_url( trim( $author_uri[1]) );}}}

preg_match returns FALSE upon an error, or 0 or 1 $matches found. It is possible for no $matches to be found causing $matches[1] to be undefined using the conditional if ( preg_match() )

Attachments (1)

missing_theme_lines.9336.diff (1.6 KB) - added by filosofo 9 years ago.

Download all attachments as: .zip

Change History (5)

#1 @Mittineague
9 years ago

  • Cc Mittineague added

#2 follow-up: @DD32
9 years ago

Changing the regex's to (.+) should fix this possibility?

#3 in reply to: ↑ 2 @filosofo
9 years ago

  • Keywords has-patch theme added
  • Milestone changed from Unassigned to 2.8

Replying to DD32:

Changing the regex's to (.+) should fix this possibility?

No, because if you had for example just "Theme URI:" the parentheses would capture nothing and put it in $theme_uri[1], avoiding the undefined notice. This happens when there's no Theme URI line whatsoever; the preg_match returns false, but later on the $theme_uri[1] is used.

#4 @azaozz
9 years ago

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

(In [10825]) Fix notice in wp-includes/theme.php, props filosofo, fixes #9336

Note: See TracTickets for help on using tickets.