module.tag.id3v1.php undefined index 'genre' bug

Locked
darren
User
Posts: 1
Joined: Mon Nov 03, 2008 4:55 pm

module.tag.id3v1.php undefined index 'genre' bug

Post by darren » Thu Nov 13, 2008 9:31 am

On line 63 of module.tag.id3v1.php I get an undefined index warning.

The line looks like this:

Code: Select all

$this->LookupGenreID(@$ParsedID3v1['genre']),
But should probably rather look like this

Code: Select all

(isset($ParsedID3v1['genre'])) ? $this->LookupGenreID(@$ParsedID3v1['genre']) : fal
se,

If one has a look at the LookupGenreId method you will see that the 2nd last line bello will never be reached and even if it does the warning will already have been thrown on line 63:

Code: Select all

function LookupGenreID($genre, $allowSCMPXextended=false) {
		$GenreLookup = getid3_id3v1::ArrayOfGenres($allowSCMPXextended);
		$LowerCaseNoSpaceSearchTerm = strtolower(str_replace(' ', '', $genre));
		foreach ($GenreLookup as $key => $value) {
			foreach ($GenreLookup as $key => $value) {
				if (strtolower(str_replace(' ', '', $value)) == $LowerCaseNoSpaceSearchTerm) {
					return $key;
				}
			}
			return false;
		}
		return (isset($GenreLookup[$genreid]) ? $GenreLookup[$genreid] : false);
	}
I always like to develop with strict error and warning levels on to catch these type of things.
Thanks for the great code and all your hard work.

Locked