When executing a foreach ($ht as &$ref), foreach calls zend_hash_iterator_pos_ex() on every iteration. If the HashTable contained in the $ht variable is not the tracked HashTable, it will reset the position to the internal array pointer of the array currently in $ht.
This behaviour is generally fine, but undesirable for copy-on-write copies of the iterated HashTable. This may trivially occur when the iterated over HashTable is assigned to some variable, then the iterated over variable modified, leading to array separation, changing the HashTable pointer in the variable. Thus foreach happily restarting iteration.
This behaviour (despite existing since PHP 7.0) is considered a bug, if not only for the behaviour being unexpected to the user, also copy-on-write should not have trivially observable side-effects by mere assignment.
The bugfix consists of duplicating HashTableIterators whenever zend_array_dup() is called (the primitive used on array separation).
When a further access to the HashPosition through the HashTableIterators API happens and the HashTable does not match the tracked one, all the duplicates (which are tracked by single linked list) are searched for the wanted HashTable. If found, the HashTableIterator is replaced by the found copy and all other copies are removed.
This ensures that we always end up tracking the correct HashTable.
Fixes GH-11244.
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
This improves FastCGI client by separating transport functions and adding support for more low level socket transport that is useful for debugging in some cases.
In addition to that it introduces an option for delaying of fcgi request writing.
This PR introduces a new way of recursion protection in JSON, var_dump
and friends. It fixes issue in master for __debugInfo and also improves
perf for jsonSerializable in some cases. More info can be found in
GH-10020.
Closes GH-11812
On one of the nightly CI builds last week, there were test failures in
mbstring which appear like they might be related to SIMD-accelerated
code. The function which failed testing has multiple implementations,
and the specific implementation which is used depends on the features of
the host CPU and the build configuration.
The CI build log does not offer any clues about what implementation
was actually used when the tests failed. If the same thing happens
again, it will be helpful to (at least) know what CPU features the host
CPU supports. This will also be helpful when diagnosing any other CI
build failures which relate to CPU-specific code (or those which
related to external packages such as ICU).
It would be better to print even more information about the build
configuration. It would also be better to print host CPU information
on Windows CI builds as well.
As reported in GH-12024, the test fails in the encoding part of the test
file. This is due to a libxml2 bug (that's been fixed in modern
versions, but of course various systems and distros are always behind).
The goal of this part of the test is to check if an encoding declaration
is outputted. So the actual encoding used doesn't matter.
Switch to UTF-8, which seems to always work, to work around the issue.
* Zend: Make zend_strnlen available for use outside zend_compile
* exif: remove local php_strnlen, use zend_strnlen instead
* main: remove local strnlen, use zend_strnlen instead
* phar: remove local strnlen, use zend_strnlen
By default phpdbg is enabled (--enable-phpdbg) and user can get info in
the `./configure --help` output if they want to disable it like with the
other configuration options.
This fixes builds without cgi or phpdbg:
./configure --disable-cgi --disable-phpdbg
make
./sapi/cli/php run-tests.php
Otherwise, deprecation warnings (since PHP-8.1) are emitted:
Deprecated: escapeshellarg(): Passing null to parameter #1 ($arg) of
type string is deprecated in run-tests.php...
This syncs the style of the --enable-mysqlnd-compression-support option
name, otherwise in Autoconf both --enable-foo_bar and --enable-foo-bar
work.
Also the configure output message is synced to match the check
information.
Within the entire repository these are documentation files and CI don't
need to run when they are changed.
This now includes also README.REDIST.BINS, README.md, and similar README
files within the sapi and ext directories.
README files in tests directories are also only for internals
documentations purposes.
Because the failure path did not release the string, there was a memory
leak.
As the only valid types for this function are IS_NULL and IS_STRING, we
and IS_NULL is always rejected in practice, solve the issue by not using
a function that increments the refcount in the first place.
Closes GH-12002.