The AC_STRUCT_ST_BLOCKS expects fileblocks object to be compiled with
AC_LIBOBJ if stat.st_blocks is missing on the system. This can be
simplified with the usual AC_CHECK_MEMBERS since PHP is using the
stat.st_blocks (and stat.st_blksize) conditionally.
These members are mostly present on all POSIX-based systems except on
Windows these days.
This also removes the obsolete HAVE_ST_BLOCKS symbol:
https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/types.m4?h=v2.72#n1055
Additionally, the st_blksize and st_blocks members are checked
conditionally with HAVE_ preprocessor macros. Instead of filtering
Windows specifically here, the preprocessor macros
HAVE_STRUCT_STAT_ST_BLKSIZE and HAVE_STRUCT_STAT_ST_BLOCKS can be used.
The current code causes the phar entry to remain in the fname cache.
This would be fine for uncompressed phars, but is a problem for
compressed phars when they try to reopen the file pointer.
The reopen code will try to use the compressed file pointer as if it
were an uncompressed file pointer. In that case, for the given test, the
file offsets are out of bounds for the compressed file pointer because
they are the uncompressed offsets. This results in empty files.
In other cases, it's possible to read compressed parts of the file that don't
belong to that particular file.
To solve this, we simply remove the phar entry from the fname cache if
the file pointer was closed but the phar is compressed. This will make
sure that reopening the phar will not go through the cache and instead
opens up a fresh file pointer with the right decompression settings.
Closes GH-20754.
This stopped working after e735d2bc3b because fp_refcount is increased,
making phar think that the file has open read pointers.
To fix this, the refcount shouldn't be increased but that would
re-introduce the previous bug.
Instead, we need to add a field that "locks" the existence of the
internal entry separate from the refcount.
Closes GH-20473.
The size of `got` was incorrect: it being unsigned means that the error
return codes are converted from -1 to SIZE_MAX. We should use ssize_t
instead.
Closes GH-20735.
While it is possible to return a custom SplFileInfo object in the
iterator used by buildFromIterator(), the data is not actually used from
that object, instead the data from the underlying internal structure is
used. This makes it impossible to override some metadata such as the
path name and modification time.
The main motivation comes from two reasons:
- Consistency. We expect our custom methods to be called when having a
custom object.
- Support reproducibility. This is the original use case as requested in
[1].
Add support for this by calling the getMTime() and getPathname() methods
if they're overriden by a user class.
[1] https://github.com/theseer/Autoload/issues/114.
In 61884c3b52 I added these FIXME comments after I noticed that this
would cause an assertion failure. At that time I did not yet know what
to do here. I took a look at the code now and other streams return -1
and leave the file position untouched. So we do the same for phar.
This fixes the assertion failure and subsequent crashes, but also
changes one test output. However, I believe the new test output is
correct.
Closes GH-20475.