ZF-7242: *_MimeType:isValid() - doesn't use finfo when possible

Issue Type: Bug Created: 2009-07-10T15:37:17.000+0000 Last Updated: 2009-07-11T08:44:37.000+0000 Status: Resolved Fix version(s): - 1.9.0 (31/Jul/09)

Reporter: Dustin Sweigart (dustins) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate_File

Related issues: Attachments:


This problem is also seen in Zend_Transfer_Adapter_Abstract::getMimeType().

finfo will not be used to determine mime type because the magic file and the 'MAGIC' constant isn't set. However finfo works without this in php 5.3. So the mime type uses one of the lesser methods.


Posted by Thomas Weidner (thomas) on 2009-07-10T15:44:57.000+0000

finfo works also in 5.2.4 without setting the magic constant.

When you want to use a own magic file you must also set the related option. There is no way to detect which mime database you want to use when you don't set it and your php.ini does also not give a proper location.

This is not a ZF issue, this is just a mis-configuration of your php.ini file. See the ZF documentation for details.

Posted by Dustin Sweigart (dustins) on 2009-07-10T16:36:35.000+0000

Can I suggest the documentation be changed then? It isn't consistent with how the finfo constructor behaves... {quote} Name of a magic database file, usually something like /path/to/magic.mime. If not specified, the MAGIC environment variable is used. If this variable is not set either, /usr/share/misc/magic is used by default. A .mime and/or .mgc suffix is added if needed. {quote}

Surely it would be easy to assign the browser given mime type to $this->_type by default and then replace it if finfo is available and can be constructed or if mime_content_type() is available. This would create more consistency with finfo itself and allow more people to use it without making demands of their php.ini file that aren't actually a requirement (or mis-configuration) by finfo/PHP.

Posted by Thomas Weidner (thomas) on 2009-07-11T08:21:41.000+0000

How finfo behaves depends on your OS and your settings. When you have not configured finfo properly there is no way for ZF to use it.

The magic constant defines when the magic file can be found. There is no way to find this file automatically.

Still, when you have problems with finfo you should first take a look into php's finfo manual page. ZF should not double php's manual on how extensions should be configured.

Posted by Thomas Weidner (thomas) on 2009-07-11T08:44:36.000+0000

Changed recognition of finfo with r16645

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.