Last modified: 2010-05-15 15:42:51 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 8337 - Image pages with PNG images display once, then get fileicon.png instead
Image pages with PNG images display once, then get fileicon.png instead
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
1.8.x
PC Windows XP
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-12-20 16:10 UTC by Jason Armistead
Modified: 2010-05-15 15:42 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jason Armistead 2006-12-20 16:10:44 UTC
Platform: XAMPP 1.5.4a running on Windows XP Professional.  PHP 5.1.6. Apache reports 
Server: Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8d mod_autoindex_color 
PHP/5.1.6

When a PNG image is uploaded, and then the Image: page is viewed, on the first viewing it 
displays correctly as expected with an appropriate size thumbnail, but if you refresh the 
page, the PNG is replaced by fileicon.png, which is used when an unknown file type is 
presented.

So what happened between first and second loadings of the page ?

Well, I discovered that my PHP magic.mime file from XAMPP is broken.  Running php -i from 
the command line showed:

mime_magic

mime_magic support => invalid magic file, disabled

Directive => Local Value => Master Value
mime_magic.debug => Off => Off
mime_magic.magicfile => C:\Program Files\xampp\php\extras\magic.mime => C:\Program 
Files\xampp\php\extras\magic.mime

I noticed something odd, it was mapping PNG files into image/x-png

I had another look at an affected file, in this case one from Wikimedia Commons

http://en.wikipedia.org/wiki/Image:Canterbury_Tales.png

which I had copied onto my system (since it was referred to by some Help: pages).

The first time I looked at it, it displayed with 

Canterbury_Tales.png‎ (26KB, MIME type: image/png)

but when I reloaded it it changed to

Canterbury_Tales.png‎ (26KB, MIME type: image/x-png)

and the image was replaced by the generic fileicon.png in function iconThumb of Image.php

What was going on ?

I looked into image table of MySQL using phpMyAdmin, and sure enough, all my PNG images 
had img_minor_mime field set in their records to x-png instead of png.  That explained 
what was going on for the SECOND time I viewed the page - somehow it was getting the mime 
type from the image table as image/x-png, then deciding it couldn't handle it.

But why was it working for the FIRST time I viewed the Image: page ?

I am still not sure what changes in this case.  But it definitely looks as though 
MediaWiki is using two different methods for getting the MIME type, possibly one related 
directly to file extension and the other relating to file magic numbers derived by PHP.

I fixed up my magic.mime file, ran php maintenance/rebuildImages.php to fix up the image 
table.  The problem has not re-appeared.

Yes, part of the problem was the broken magic.mime file supplied with XAMPP, but the 
other problem, and the one I want to highlight is the broken way that MediaWiki displayed 
the Image: page OK the first time but not the second (and subsequent) times.  The code is 
somehow inconsistent.  I suspect that without my broken magic.mime file, I may never have 
uncovered this bug.
Comment 1 Rob Church 2006-12-20 16:31:02 UTC
It's quite simple; MediaWiki used a PHP function to do the MIME detection, and
then saved this result in the database to save time later, among other things.
The trouble is, if the result we get is wrong, we don't know that, and we store
it regardless.

The "fix" for this, as discovered, is to run maintenance/rebuildImages.php to
fix up the MIME types in the database.
Comment 2 Jason Armistead 2006-12-20 17:01:15 UTC
Thanks Rob for your reply

In my situation, I have an SQL dump taken from a server with broken magic.mime file.

The image table fields already say x-png for img_minor_mime

Yet when I view any of these Image: pages which are PNG files the first time, it isn't 
looking at the database (or doesn't appear to be).  It's somehow getting it right 
first time and displaying the image, and then getting it wrong (which I guess is when 
it IS referring to the stored copy you refer to) and showing the MIME type of image/x-
png.

I expected it to either get it wrong all the time or get it right all the time, which 
does not coincide with my experience.
Comment 3 Antoine "hashar" Musso (WMF) 2008-08-28 17:30:03 UTC
Closing this bug since it is more like a support request.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links