Bug #55781 [Opn->Fbk]: exif_read_file assumes only stdio supports stat(), performs slow seek to end
| From: | kalle@php.net | Date: | Fri, 05 Aug 2016 06:09:30 +0000 |
| Subject: | Bug #55781 [Opn->Fbk]: exif_read_file assumes only stdio supports stat(), performs slow seek to end | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202938@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55781&edit=1
ID: 55781
Updated by: kalle@php.net
Reported by: tom at punkave dot com
Summary: exif_read_file assumes only stdio supports stat(),
performs slow seek to end
-Status: Open
+Status: Feedback
Type: Bug
Package: EXIF related
Operating System: All
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
I'm not sure whether or not this is possible, as the http wrapper do not support stat() calls,
which means we would need to add specific code for different protocols in ext/exif, or just for
http(s).
We could look into adding support for stat on the HTTP wrapper, however I'm not sure which data
we could translate into what.
I personally lean a little towards the first one, but for the overall good of the PHP codebase, I
think the second option is most beneficial for other extensions at the same time that could need
such.
Previous Comments:
------------------------------------------------------------------------
[2011-09-25 18:17:30] tom at punkave dot com
Description:
------------
Per Twitter exchange with @pierrejoye
The exif_read_file function checks whether the file is accessed over stdio. If
it is accessed over stdio, VCWD_STAT() is used to get the size of the file
efficiently. If it is accessed by any other means, this pattern is used:
php_stream_seek(ImageInfo->infile, 0, SEEK_END);
ImageInfo->FileSize = php_stream_tell(ImageInfo-
>infile);
php_stream_seek(ImageInfo->infile, 0, SEEK_SET);
Moving the seek pointer to the end can trigger slow, bandwidth-hungry network
operations for remote stream wrappers, such as S3 wrappers.
Please test whether the stream implements the stat operation and, if so, use it
to avoid this performance hit.
I was able to work around the problem by teaching my stream wrapper to
specifically tolerate the "seek to the end / ftell / seek to the start" pattern
and return cached data.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55781&edit=1