MediaHandler::isMetadataInvalid() should return METADATA_BAD only when there is something wrong with the metadata, not when there is something wrong with the file. A file validation error should never cause isMetadataValid() to return false, since this causes upgradeRow() to be called every time the image is used in any way.
The SVG and DjVu handlers get this wrong. This causes high DB master load, and also errors such as bug 27639.
I would humbly point to OggHandler as a possible model for appropriate handling of invalid files: an invalid file causes an error message to be saved into the metadata array, and then getLongDesc() is overridden to display the error message to the user on the image description page. getWidth() etc. returns zero for an invalid file.