1
0
mirror of https://github.com/php/php-src.git synced 2026-03-29 19:52:20 +02:00
Commit Graph

68732 Commits

Author SHA1 Message Date
Daniel Scherzer
81f143e71f Reflection: indicate final and abstract properties in string output
Add "final" and "abstract" to the result of `_property_string()` when
outputting the string representation of a `ReflectionClass` or
`ReflectionProperty` instance

Closes GH-17827
2025-02-25 12:21:15 +01:00
Dmitry Stogov
819b1988a0 Update IR
IR commit: ca93e781eaf6b0949690d3df272ecf44528ff4a8
2025-02-25 02:23:05 +03:00
Jakub Zelenka
ed00c1d74b Merge branch 'PHP-8.3' into PHP-8.4 2025-02-24 23:22:47 +01:00
Jakub Zelenka
930624899b Fix bug #72666: stat cache not cleared for plain paths
This adds more aggressive clearing of stat cache. It is added to the
filestat as well as plain wrapper operations which covers stream file
accessing as well as exec functions (using pipes). It should hopefully
fix the most visible issues with the stat cache.

Closes GH-17681
2025-02-24 23:21:45 +01:00
Niels Dossche
3b4a58da44 Backport GH-17869 to PHP 8.3 JIT
Closes GH-17918.
2025-02-24 21:45:03 +01:00
Niels Dossche
5ede5415e1 Fix GH-17868: Cannot allocate memory with tracing JIT on 8.4.4
The generated code tries to initialize the run time cache for even
internal closures, but it should only initialize the run time cache for
user closures. We fix this by adding a check for the function type.
If `func` is known, then we can check the type at code generation time.

Closes GH-17869.
2025-02-24 19:36:13 +01:00
Bob Weinand
53fa98ecd3 Fix GH-17715: Handle preloaded internal function runtime cache (#17835)
This solely affects the builtin enum functions currently.

Given that these are stored in SHM, we cannot simply hardwire a pointer into the internal function runtime cache on NTS too, but have to use a MAP_PTR (like on ZTS).
Now, by design, the runtime cache of internal functions no longer is reset between requests, hence we need to store them explicitly as static runtime cache.

On NTS builds we cannot trivially move the pointers into CG(internal_run_time_cache) as they're directly stored on the individual functions (on ZTS we could simply iterate the static map_ptrs).
Hence, we have the choice between having opcache managing the internal run_time_cache for its preloaded functions itself or realloc CG(internal_run_time_cache) and iterate through all functions to assign the new address. We choose the latter for simplicity and initial speed.
2025-02-24 14:35:47 +01:00
David Carlier
fc73da57f4 Merge branch 'PHP-8.3' into PHP-8.4 2025-02-24 07:14:56 +00:00
Michael Orlitzky
174a7fe6f9 Fix GH-17891 gh17373.phpt test issue without freetype support
skip if imagefttext() is not available

This test calls imagefttext(), which may not be available if libgd
was built without freetype support.

Closes GH-17910
2025-02-24 07:13:11 +00:00
Michael Orlitzky
065b4ec125 ext/gd/tests: backport optional PNG support
- Three of our gd tests could be skipped with a message about requiring
bundled GD, but those tests don't actually require bundled GD. We
update the messages to mention the specific functions that are
required.

- add SKIPIF stanzas for missing PNG support

The bundled libgd always has PNG support, but an external one may not.

- imagerotate() is always available

Following 59ec80c5, the imagerotate() function is always available. We
may therefore remove its function_exists() checks without harm.

close GH-17894
2025-02-23 16:01:30 +00:00
Niels Dossche
635fe263ac Fix memory leaks in pdo_sqlite callback registration
* We need to clean the trampoline if the construction check fails
* Checking for an exception and then returning causes a leak on
  `collation`. Returning early is pointless anyway.

Closes GH-17904.
2025-02-23 16:35:55 +01:00
Niels Dossche
76035090b6 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix cycle leak in sqlite3 setAuthorizer()
2025-02-23 16:35:25 +01:00
Niels Dossche
353f21487f Fix cycle leak in sqlite3 setAuthorizer()
Closes GH-17903.
2025-02-23 16:34:41 +01:00
David Carlier
96340e9eed Merge branch 'PHP-8.3' into PHP-8.4 2025-02-23 13:23:38 +00:00
David Carlier
2c251f945c [skip ci] zend_test adding closing tags to newer tests 2025-02-23 13:23:26 +00:00
David Carlier
e8dda54dd5 Merge branch 'PHP-8.3' into PHP-8.4 2025-02-23 10:45:46 +00:00
David Carlier
cefdf00e7e Fix GH-17899: zend_test_compile_string crash on invalid script path.
when opcache is enabled.

close GH-17901
2025-02-23 10:45:10 +00:00
Niels Dossche
7974c62873 Fix using Dom\Node with Dom\XPath callbacks
This code was introduced when the Dom\Node and DOMNode classes were
still aliases, so the type check was never updated.
We fix this by checking if the doc pointer follows the spec and pick the
right node CE based on that.

Closes GH-17888.
2025-02-22 16:00:39 +01:00
Christoph M. Becker
2c911e400a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17879: readfile_variation8-win32.phpt test conflict
2025-02-22 00:10:51 +01:00
Christoph M. Becker
769f292a7a Fix GH-17879: readfile_variation8-win32.phpt test conflict
Apparently a copy and paste issue.

Closes GH-17881.
2025-02-22 00:09:53 +01:00
Niels Dossche
be3d128632 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17847: xinclude destroys live node
2025-02-21 22:27:53 +01:00
Niels Dossche
9becccef17 Fix GH-17847: xinclude destroys live node
dom_xinclude_strip_fallback_references() now also takes into account
xi:include nodes children. This now subsumes all work done normally by
the old start/end node removal, so we can remove that code and start
using XML_PARSE_NOXINCNODE.

Closes GH-17878.
2025-02-21 22:24:44 +01:00
Christoph M. Becker
200f16fcf7 Fix GH-17855: CURL_STATICLIB flag set even if linked with shared lib
We must define `CURL_STATICLIB` only when building against a static
libcurl.  The detection relies on our usual naming conventions, what
should be revised in the future (possibly using pkg-config, or
switching to CMake).

Closes GH-17857.
2025-02-21 13:08:01 +01:00
Christoph M. Becker
07a3719bc7 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17855: CURL_STATICLIB flag set even if linked with shared lib
2025-02-21 12:49:08 +01:00
Christoph M. Becker
29c39a3d91 Fix GH-17855: CURL_STATICLIB flag set even if linked with shared lib
We must define `CURL_STATICLIB` only when building against a static
libcurl.  The detection relies on our usual naming conventions, what
should be revised in the future (possibly using pkg-config, or
switching to CMake).

Closes GH-17857.
2025-02-21 12:46:20 +01:00
Niels Dossche
77847b02b9 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Reflection: show the type of object constants used as default properties
2025-02-21 09:36:01 +01:00
Daniel Scherzer
ca0414e64d Reflection: show the type of object constants used as default properties
When a property default is based on a global constant, show the type of the
default. Previously, `format_default_value()` assumed that non-scalar and
non-array defaults were always going to be `IS_CONSTANT_AST` pointers, and when
the AST expression had been evaluated and produced an object, depending on when
the `ReflectionClass` or `ReflectionProperty` instance had been created, the
default was shown as one of `callable` or `__CLASS__`.

Instead, if the default value is an object (`IS_OBJECT`), show the type of that
object.

Add test cases for both of the `callable` and `__CLASS__` cases to confirm that
they now properly show the type of the constant.

Closes GH-15902.
Closes GH-17781.
2025-02-21 09:32:10 +01:00
Dmitry Stogov
dd404dc419 Update IR
IR commit: 1499748be439e7f786c0ee2c4f738c126af57df8
2025-02-20 23:58:08 +03:00
Remi Collet
04a33a1122 zip version is now 1.22.5 2025-02-20 11:47:51 +01:00
Dmitry Stogov
352aca1ee1 Update IR
IR commit: 7f920cb660a1ef615a3059eab77b86ca1a43121e
2025-02-18 21:32:17 +03:00
Christoph M. Becker
4a514f653a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17837: ::getColumnMeta() on unexecuted statement segfaults
2025-02-18 17:03:00 +01:00
Christoph M. Becker
260e0e9bd3 Fix GH-17837: ::getColumnMeta() on unexecuted statement segfaults
We cannot properly get the column meta data of a statement which has
been prepared, but has not yet been executed.  As such we bail out
early, reporting failure.

Closes GH-17850.
2025-02-18 17:01:46 +01:00
Niels Dossche
74df3e0404 Fix lowercase HTML attribute exceptions
Closes GH-17815.
2025-02-17 19:31:50 +01:00
Niels Dossche
3a4a320386 Fix GH-17802: \Dom\HTMLDocument querySelector attribute name is case sensitive in HTML
According to https://html.spec.whatwg.org/#case-sensitivity-of-selectors,
the CSS selector attribute name must be converted to lowercase in HTML elements,
and then compared case-sensitive to the attribute name in the element.
We implement this not by doing the explicit conversion, but by a manual
loop using a function that first converts the rhs characters to
lowercase and keeps the lhs characters the same, achieving the same
effect.
2025-02-17 19:31:23 +01:00
Dmitry Stogov
ddde315035 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix FFI Parsing of Pointer Declaration Lists (#17794)
2025-02-17 10:27:33 +03:00
David Zhong
52c91f0fb7 Fix FFI Parsing of Pointer Declaration Lists (#17794)
* Fix ffi parsing of pointer declaration lists

* Fix ffi pointer declaration lists grammar
2025-02-17 10:27:11 +03:00
Christoph M. Becker
8a6370d7a9 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Adapt tests to Windows 11
2025-02-17 00:08:43 +01:00
Christoph M. Becker
765cebf73a Adapt tests to Windows 11
Apparently, one of the more recent patch releases of Windows 10
(confirmed for Windows 10.0.26100, but may affect older versions, too)
changed treatment of filenames with trailing slashes to be recognized
explicitly as directories, and no longer as invalid file or directory.

We adapt the affected test cases.

Closes GH-17804.
2025-02-17 00:07:55 +01:00
Niels Dossche
d6c3079910 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [ci skip] Fix GH-17808 dependencies
2025-02-16 00:17:06 +01:00
Niels Dossche
3e879f3dd5 [ci skip] Fix GH-17808 dependencies 2025-02-16 00:16:57 +01:00
Niels Dossche
5d8ea65f43 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17808: PharFileInfo refcount bug
2025-02-15 13:16:33 +01:00
Niels Dossche
e735d2bc3b Fix GH-17808: PharFileInfo refcount bug
PharFileInfo just takes a pointer from the manifest without refcounting
anything. If the entry is then removed from the manifest while the
PharFileInfo object still exists, we get a UAF.
We fix this by using the fp_refcount field. This is technically a
behaviour change as the unlinking is now blocked, and potentially file
modifications can be blocked as well. The alternative would be to have a
field that indicates whether deletion is blocked, but similar corruption
bugs may occur as well with file overwrites, so we increment fp_refcount
instead.
This also fixes an issue where a destructor called multiple times
resulted in a UAF as well, by moving the NULL'ing of the entry field out
of the if.

Closes GH-17811.
2025-02-15 13:15:51 +01:00
David Carlier
eabbb1c1c6 Merge branch 'PHP-8.3' into PHP-8.4 2025-02-15 10:12:20 +00:00
David Carlier
0f63bee3e9 Fix GH-17797: zend_test_compile_string crash on invalid script path.
When looking for the last slash of the script path, it leads to
underflow being promoted to SIZE_MAX being way beyond MAXPATHLEN.

close GH-17801
2025-02-15 10:11:27 +00:00
Niels Dossche
8f8d4be5eb Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix zlib support for large files
  Fix memory leak on overflow in _php_stream_scandir()
2025-02-14 23:10:40 +01:00
Niels Dossche
5aaf7b4937 Fix zlib support for large files
gzread() and gzwrite() have effectively a 4GiB limit at the moment
because the APIs of the zlib library use unsigned ints.
For example, this means that the count argument of gzread() and gzwrite()
& co effectively are modulo 2**32.
Fix this by adding a loop to handle all bytes.

As for automated testing, I didn't find an easy way to write a phpt for
this that wouldn't use a lot of memory or requires a large file.
For instance, the gzread() test that I manually ran requires a 4MiB
input file (and I can't shrink it because zlib has a max window size).

Here are the testing instructions, run on 64-bit:
To test for gzwrite():
```php
$f = gzopen("out.txt.gz", "w");
gzwrite($f, str_repeat('a', 4*1024*1024*1024+64)); // 4GiB + 64 bytes
```
Then use `zcat out.txt.gz|wc -c` to check that all bytes were written
(should be 4294967360).

To test for gzread():
Create a file containing all a's for example that is 4GiB + 64 bytes.
Then compress it into out.txt.gz using the gzip command.
Then run:
```php
$f = gzopen("out.txt.gz", "r");
$str = gzread($f, 4*1024*1024*1024+64);
var_dump(strlen($str)); // 4294967360
var_dump(substr($str, -3)); // string (3) "aaa"
```

Closes GH-17775.
2025-02-14 23:09:57 +01:00
David Carlier
ed18fd073a Merge branch 'PHP-8.3' into PHP-8.4 2025-02-14 15:28:48 +00:00
David Carlier
4d7d01d18e Fix GH-17772: imagepalettetotruecolor segfault on invalid truecolor pixel.
close GH-17777
2025-02-14 15:28:33 +00:00
Ilija Tovilo
5b87faaaa7 Fix curl protocols test expectation
Closes GH-17803
2025-02-14 14:38:34 +01:00
Niels Dossche
902e01f4f9 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak when encoding check fails
2025-02-13 19:10:46 +01:00