**Steps to replicate the issue** (include links if applicable):
* Set up MediaWiki with MySQL
* Enable file upload and add additional allowed extension
* `$wgEnableUploads = true;`
* `$wgFileExtensions = [ 'png', 'gif', 'jpg', 'jpeg', 'webp', 'ttf' ];`
* If working in development mode, disable strict warnings `$wgDBStrictWarnings = false;`, otherwise enable strict SQL Mode `$wgSQLMode = 'STRICT_ALL_TABLES';`.
* Upload file with a non-standard extension, eg. `.ttf`.
* You can notice that the file is saved in the `image` table with `''`/`0` value in `img_major_mime` column
* Now try to delete the file
**What happens?**:
There is an error, and the file cannot be deleted:
```
Wikimedia\Rdbms\DBQueryError from line 1627 of /includes/libs/rdbms/database/Database.php: Error 1265: Data truncated for column 'fa_major_mime' at row 1
Function: LocalFileDeleteBatch::doDBInserts
Query: INSERT INTO `filearchive` ...
```
MediaWiki tried to move the record from the `image` table to the `filearchive` table, but it was impossible because `fa_major_mime` is an enum, and `''`/`0` value is not allowed when MySQL is configured to work in a strict mode.
The `img_major_mime` column in the `image` table has a similar enum, but image upload works, because the code appends `IGNORE` to the `INSERT` statement, and MySQL converts the not-allowed enum value to `''`/`0``.
**What should have happened instead?**:
The file should be deleted.
**Software version** (skip for WMF-hosted wikis like Wikipedia):
Latest code from the `master`, but also older versions, eg. `1.39`.
I'll submit two patches that could fix this issue:
1. Stop producing data with invalid enum values, by using an `unknown` value for cases when the calculated mime is different than allowed by the database schema.
2. Allow deletion of files with invalid `img_major_mime` values, by using `IGNORE` in the `INSERT` to `filearchive` table statement. It could alternatively be replaced by a database update fixing bad records.