(Tests needed) Stream wrappers stream_seek() return is invalid

Created on 4 July 2010, almost 15 years ago
Updated 28 March 2025, about 1 month ago

The PHPdoc for stream_seek() says:

  /**
   * Support for fseek().
   *
   * @param $offset
   *   The byte offset to got to.
   * @param $whence
   *   SEEK_SET, SEEK_CUR, or SEEK_END.
   *
   * @return
   *   TRUE on success.
   *
   * @see http://php.net/manual/en/streamwrapper.stream-seek.php
   */

and the current implementation of stream_seek() returns the result of a fseek() call, which is documented as having a different return value on http://www.php.net/manual/en/function.fseek.php:

fseek()
Return Values:
Upon success, returns 0; otherwise, returns -1. Note that seeking past EOF is not considered an error.

So, for success, stream_seek() should return TRUE but fseek() returns 0.

The bug is noticeable when the image API calls getimagesize() for a .jpg image that has some EXIF metadata that it has to skip over (using fseek())

πŸ“Œ Task
Status

Fixed

Version

11.0 πŸ”₯

Component

file system

Created by

πŸ‡³πŸ‡ΏNew Zealand asimmonds

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024