Commit 84423004 authored by Joe Hoyle's avatar Joe Hoyle
Browse files

Fix getimagesize() calls on larger JPEGs

When SEEKing from the remote stream, we were not looping the fread() call, so if the required length was bigger than the chunk size, things broke.
parent 26803acb
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -420,7 +420,6 @@ class StreamWrapper
	 */
	public function mkdir($path, $mode, $options)
	{
		error_log($path);
		$params = $this->getParams($path);
		$this->clearStatInfo($path);

+23 −11
Original line number Diff line number Diff line
@@ -106,6 +106,13 @@ class CachingEntityBody extends AbstractEntityBodyDecorator

        // More data was requested so read from the remote stream
        if ($remaining) {

            /**
             * Modification by Joe Hoyle, we do a while loop to geet reading data, 
             * as the ramainging amount of data to fetch from the remote stream could
             * be more than the chunk size.
             */
            while( $remaining > 0 ) {
                // If data was written to the buffer in a position that would have been filled from the remote stream,
                // then we must skip bytes on the remote stream to emulate overwriting bytes from that position. This
                // mimics the behavior of other PHP stream wrappers.
@@ -117,10 +124,15 @@ class CachingEntityBody extends AbstractEntityBodyDecorator
                    $this->skipReadBytes = max(0, $this->skipReadBytes - $len);
                }

                $remaining -= strlen( $remoteData );

                $data .= $remoteData;
                $this->body->write($remoteData);
            }
            

        }

        return $data;
    }