Copy warnings and errors from xxx_writer to tag_writer

Think you found a bug in getID3()? Post here with details.
Post Reply
fred727
User
Posts: 11
Joined: Wed Jun 08, 2016 6:20 pm
Are you a spambot?: no

Copy warnings and errors from xxx_writer to tag_writer

Post by fred727 » Wed Jun 08, 2016 7:20 pm

Not a bug but a suggestion.

If there is errors or warnings in an object getid3_write_id3v2 for exemple, these errors are not copied into the "top" object getid3_writetags, so we do not know they occured !!

Example :

Code: Select all

		$tagwriter = new getid3_writetags() ;
		$tagwriter->filename = 'path/to/file.mp3';
		$tagwriter->tagformats = [ 'id3v2.3' ] ;
		$tagwriter->tag_data = array(
			'title'                     => [ 'my title' ],
			'url_artist'                      => [ 'not a @url !' ],
		);
		$ok = $tagwriter->WriteTags() ;  /* uses getid3_write_id3v2 ! */
		/* We don't avec access to the [i]getid3_write_id3v2[/i] object here ! No property for that in $tagwriter... */
		var_dump($tagwriter->errors); /* nothing... */

James Heinrich
getID3() v1 developer
Posts: 1432
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Copy warnings and errors from xxx_writer to tag_writer

Post by James Heinrich » Mon Jun 13, 2016 1:26 am

Actually they are copied, albeit in a slightly modified form. For example:
https://github.com/JamesHeinrich/getID3 ... #L281-L283

fred727
User
Posts: 11
Joined: Wed Jun 08, 2016 6:20 pm
Are you a spambot?: no

Re: Copy warnings and errors from xxx_writer to tag_writer

Post by fred727 » Tue Jun 21, 2016 9:40 am

The problem is that $id3v2_writer->WriteID3v2() can return true even if errors/warnings occur.
(this is the case in my exemple above)

James Heinrich
getID3() v1 developer
Posts: 1432
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Copy warnings and errors from xxx_writer to tag_writer

Post by James Heinrich » Tue Jun 21, 2016 12:21 pm

As with everywhere in getID3, a warning is non-fatal and an error is fatal -- WriteID3v2() should return false if any errors occurred (write.id3v2.php lines 127-134):

Code: Select all

if (!empty($this->errors)) {
	return false;
}
return true;

Post Reply