Bug 858653
| Summary: | fileinfo extension: use stat function from stream wrapper | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Jani Ollikainen <bestis+rh> | |
| Component: | php | Assignee: | Remi Collet <rcollet> | |
| Status: | CLOSED ERRATA | QA Contact: | Lukáš Zachar <lzachar> | |
| Severity: | unspecified | Docs Contact: | ||
| Priority: | unspecified | |||
| Version: | 6.3 | CC: | dkutalek, jorton, rcollet | |
| Target Milestone: | rc | |||
| Target Release: | --- | |||
| Hardware: | All | |||
| OS: | Linux | |||
| Whiteboard: | ||||
| Fixed In Version: | Doc Type: | Bug Fix | ||
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 869697 (view as bug list) | Environment: | ||
| Last Closed: | 2013-02-21 10:14:29 UTC | Type: | Bug | |
| Regression: | --- | Mount Type: | --- | |
| Documentation: | --- | CRM: | ||
| Verified Versions: | Category: | --- | ||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
| Cloudforms Team: | --- | Target Upstream Version: | ||
| Embargoed: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 869697 | |||
|
Description
Jani Ollikainen
2012-09-19 10:27:30 UTC
Forgot to mention about the workaround that of course it's very bad with big files as now the whole file is loaded to string before trying to figure out what it is. If one has big files, probably just reading max 1k of the file would be better and then giving that to buffer(). Hi, thanks for contacting us. finfo::file() takes a filename argument by string. Are some docs somewhere which say otherwise? http://www.php.net/manual/en/function.finfo-file.php No, filename as a argument is a string. Filename can be URI as it's a string. You see similar documentation here: http://php.net/manual/en/function.file-get-contents.php And the workaround uses that, which is documented as is that finfo-file, there's string for filename and context for stream wrappers. Ah, thanks, sorry, I missed the upstream bug reference. Fixed in http://svn.php.net/viewvc?view=revision&revision=308327 The linked upstream bug refers to "stream". Applying the upstream patch works for some stream wrappers (tested with zip, from upstream unit test). Despite this patch, your test script doesn't work (even with latest upstream PHP version 5.4.8RC1). It seems http streams are curently not supported (need stat and seek capabilities) Need more investigation. Good point. So there are two problems here: 1) the fileinfo extension does not use the stat interface from the stream wrapper. 2) the http stream wrapper does not support the stat interface The upstream patch referenced above does fix (1), but not (2). So it would fix use of e.g. zip:// URLs. We can pull in that fix. Jani, if you also require a fix for (2) can you file a new bug? Supporting http stat is an enhancement request, we'd have to get a fix accepted upstream for that. In fact my comment about the zip:// URLs was not correct for php 5.3.3; even the zip stream wrapper does not support the stat interface in that version of PHP. To ensure we are 100% clear about the scope of the fix for this bug, we are intending to fix here only part (1) mentioned in comment 7. If stream wrapper support is required for other stream types, please file new enhancements bugs so we can track those requests separately. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHSA-2013-0514.html |