Page MenuHomePhabricator

mime type detection for auto upload causes fileinfo.so crash on finfo_open
Closed, DeclinedPublic

Description

Author: jim

Description:
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
symbol "php_realpath"

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
configuration directive.

phpinfo:
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


Version: 1.9.x
Severity: normal
OS: FreeBSD
Platform: PC

Details

Reference
bz9500

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:39 PM
bzimport set Reference to bz9500.
bzimport added a subscriber: Unknown Object (MLST).

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.
Also see
http://www.gossamer-threads.com/lists/wiki/mediawiki/147360
http://www.gossamer-threads.com/lists/wiki/mediawiki/146985

Closing as WORKSFORME, but in case this still happens please reopen and provide more info (MediaWiki and PHP version).