Last modified: 2013-03-14 16:35:33 UTC
this may very well be a bug in the fileinfo.so extension for PHP, but I wanted
to post it in here in the event that someone else comes across the problem when
using MediaWiki, and perhaps so that a flag can be added to workaround the bug.
When trying to do file uploads with MediaWiki, Apache was returning an Internal
Server Error, and I found this in my logs:
/usr/libexec/ld-elf.so.1: /usr/local/lib/php/20050922/fileinfo.so: Undefined
To me, this looks like a fileinfo.so bug or a PHP bug, but I couldn't find
anything on PHP's bugzilla that looked relevant. Not wanting to go upsetting a
stable server by blindly upgrading PHP + extensions, I started digging through
the mediawiki code and traced the problem to the if block starting on line 487
in includes/MimeMagic.php. The if statement checks to see if finfo_open() and
finfo_file() are available, and uses them for Mime detection if they exist. This
was evaluating to true because my PHP installation *does* have these functions,
but there appears to be some kind of internal issue with the fileinfo library on
my server. I simply forced this if block to evaluate to false (by adding "&&
false" to the conditions) so that the block falls through to the next elseif,
which uses mime_content_type() instead. I suppose it might be reasonable to add
a flag $wgIgnoreFinfoFunctions to force MediaWiki to use mime_content_type()
instead in the presence of this issue. That is unless it's just a product of my
specific server set up (e.g. php version + fileinfo version + O/S = bug), in
which case I suppose it should still be noted, even if it doesn't warrant a new
PHP Version 5.1.6
System 4.11-STABLE FreeBSD 4.11-STABLE #0: Fri Jan i386
fileinfo support enabled
Server API CGI/FastCGI
PHP API 20041225
PHP Extension 20050922
Zend Extension 220051025
Offhand it looks like you've got a bad library; perhaps a mix of compilations
with different options or similar.
Googling turns up at least two other instances of this error, with no response,
at least one other also on FreeBSD.
Highly assuming that this was a PHP issue.
Closing as WORKSFORME, but in case this still happens please reopen and provide more info (MediaWiki and PHP version).