php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55781 exif_read_file assumes only stdio supports stat(), performs slow seek to end
Submitted: 2011-09-25 18:17 UTC Modified: 2016-08-14 04:22 UTC
From: tom at punkave dot com Assigned:
Status: No Feedback Package: EXIF related
PHP Version: 5.3.8 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tom at punkave dot com
New email:
PHP Version: OS:

 

 [2011-09-25 18:17 UTC] 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.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-05 06:09 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2016-08-05 06:09 UTC] 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.
 [2016-08-05 06:09 UTC] kalle@php.net
-Type: Bug +Type: Feature/Change Request
 [2016-08-14 04:22 UTC] php-bugs at lists dot php dot net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC