Page MenuHomePhabricator

Mixed filetypes in filehistories should be restored with the correct filetype
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

See also: T429616

https://commons.wikimedia.org/wiki/File:Population_density_of_Ireland_map.png
https://commons.wikimedia.org/wiki/File:Population_density_of_Ireland_map.svg

  1. 2008-07-16: Initial upload as PNG at Population_density_of_Ireland_map.png.
  2. 2009-10-17: SVG version uploaded over the same name.
  3. 2012-09-10: File moved from .png to .svg.
  4. 2021-11-05: Reverted to an earlier (PNG-content) revision; current revision's img_major_mime becomes image/png again.
  5. Sometime 2025: T28741 migration ran on Commons. file row created with file_type pointing to image/png — correctly reflecting the state at that moment.
  6. 2025-12-30: User Sreejithk2000 performs a history split: delete .svg, restore only the SVG-content revisions to .svg, restore PNG-content revisions to .png. After this:
    • image.img_major_mime = 'image/svg+xml' for the .svg file
    • file.file_type still references image/png — stale
  7. Rendering the file page invokes PNGHandler (because file.file_type resolves to PNG), which fails on SVG metadata that has no frameCount key.

What happens?:

Current revision of a file had the incorrect filetype, ,because it was restored and the file type was not updated. This broke the file.

What should have happened instead?:
The current revision (at the very least) should always have the correct filetype, even if it's historic filetype was broken.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

Do we have a sense scale of mixed filetypes. Before deploy of file schema, I looked at it and it wasn't that many.

We have only 38 cases of this:

file_id file_name       ft_media_type   img_media_type  ft_major_mime   img_major_mime  ft_minor_mime   img_minor_mime
884866  Zweig_-_Tolstoï.djvu    BITMAP  OFFICE  image   image   vnd.djvu        vnd.djvu
6745690 1_capozither.jpg        BITMAP  BITMAP  image   image   tiff    jpeg
14190844        Alessandria_posizione.svg       BITMAP  DRAWING image   image   png     svg+xml
15178891        Ancona_posizione.svg    BITMAP  DRAWING image   image   png     svg+xml
16418281        Arezzo_posizione_(2).svg        BITMAP  DRAWING image   image   png     svg+xml
31380873        Daisy_Bell_sung_by_DECtalk_(2).flac     AUDIO   AUDIO   audio   audio   x-flac  flac
34563068        Dmitry_Medvedev_speech_65th_Victory_Day_Parade_2010.ogv VIDEO   VIDEO   application     video   ogg     mp4
35608958        Chéjere_en_un_árbol.ogg AUDIO   VIDEO   application     application     ogg     ogg
38261094        Ether-autoxidation.svg  BITMAP  DRAWING image   image   png     svg+xml
40255169        Firma_de_Artur_Chilingarov.svg  BITMAP  DRAWING image   image   png     svg+xml
40491555        Flat_ilm_block_view_vlsi_600x540.jpg    BITMAP  BITMAP  image   image   tiff    jpeg
42079442        Frioul_mini.jpg BITMAP  BITMAP  image   image   tiff    jpeg
49181339        HyperbolaInPolarCoords.svg      BITMAP  DRAWING image   image   png     svg+xml
55524087        Italy_template.svg      BITMAP  DRAWING image   image   png     svg+xml
55890364        Jacquelin-et-Dufresne.SVG       BITMAP  DRAWING image   image   png     svg+xml
60004549        Kremer-et-Bouniol.svg   BITMAP  DRAWING image   image   png     svg+xml
62817553        Landron.svg     BITMAP  DRAWING image   image   png     svg+xml
64217498        Life_science_popart.png BITMAP  BITMAP  image   image   tiff    png
83099149        Plan-tram-rennes-1897.svg       BITMAP  DRAWING image   image   png     svg+xml
83099150        Plan-tram-rennes-1916.svg       BITMAP  DRAWING image   image   png     svg+xml
84101776        Population_density_of_Ireland_map.svg   BITMAP  DRAWING image   image   png     svg+xml
84923785        Precuneus_connectivity.jpg      BITMAP  BITMAP  image   image   tiff    jpeg
89491807        Rothschild_Extinct_Birds.djvu   BITMAP  OFFICE  image   image   vnd.djvu        vnd.djvu
95025481        Sinkholeingrykecarletonville.jpg        BITMAP  BITMAP  image   image   tiff    jpeg
99560818        TAJIMA_Kinji.jpg        BITMAP  BITMAP  image   image   tiff    jpeg
101066034       The_Big_sinagogue_in_Zaslav.jpg BITMAP  BITMAP  image   image   tiff    jpeg
105588532       Tuzet.png       BITMAP  BITMAP  image   image   tiff    png
107491982       University_medal-1.jpg  BITMAP  BITMAP  image   image   tiff    jpeg
108455434       Verenluovuttaja.png     BITMAP  BITMAP  image   image   tiff    png
114987307       Выступление_на_церемонии_инаугурации_мэра_Москвы_Сергея_Собянина.ogv    VIDEO   VIDEO   application     video   ogg     mp4
118678973       "A_Georgia_Barn_Dance",_by_Kerry_Mills_(1909).webm      VIDEO   AUDIO   video   audio   webm    webm
119102807       Awit_sa_Bohol.ogg       VIDEO   AUDIO   application     application     ogg     ogg
125015022       Mr_Kelly_-_Cleaners.ogg VIDEO   AUDIO   application     application     ogg     ogg
136450336       In_a_Clock_Store_Broadcast_269-A_1928.ogg       VIDEO   AUDIO   application     application     ogg     ogg
140184078       Sechseläuten_2026_Kinderumzug.ogg       AUDIO   VIDEO   application     application     ogg     ogg
140184079       Sechseläuten_Jugendmusik_Zürich_11_Sechseläutenmarsch.ogg       AUDIO   VIDEO   application     application     ogg     ogg
142983297       Ferrier_Fountain_video_MRD.webm AUDIO   VIDEO   audio   video   webm    webm
144099569       Triamescaptor_aotea_video.webm  AUDIO   VIDEO   audio   video   webm

Interestingly, it doesn't have the Population_density_of_Ireland_map.png file you mentioned. Maybe it got auto healed with another upload?

Query for the reproducibility:

analytics-mysql commonswiki -e "select file_id, file_name, ft_media_type, img_media_type, ft_major_mime, img_major_mime, ft_minor_mime, img_minor_mime  from file join filetypes on file_type = ft_id join image on img_name = file_name where ft_media_type != img_media_type or ft_major_mime != img_major_mime or ft_minor_mime != img_minor_mime limit 100000;" > mismatch_of_types

Its Population_density_of_Ireland_map.svg that is now broken (and is in the list).

I think if we add an extra check to the restore function, we at least make it possible to repair these.

And maybe we should have a cleanup script that 3rd parties can run ?