Req #55781 [Fbk->NoF]: exif_read_file assumes only stdio supports stat(), performs slow seek to end
Edit report at https://bugs.php.net/bug.php?id=55781&edit=1
ID: 55781
Updated by: php-bugs@lists.php.net
Reported by: tom at punkave dot com
Summary: exif_read_file assumes only stdio supports stat(),
performs slow seek to end
-Status: Feedback
+Status: No Feedback
Type: Feature/Change Request
Package: EXIF related
Operating System: All
PHP Version: 5.3.8
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2016-08-05 06:09:28] kalle@php.net
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.
------------------------------------------------------------------------
[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
Thread (3 messages)