Commit graph

131317 commits

Author SHA1 Message Date
Ilija Tovilo
bb046c7217
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Move Cirrus to nightly only, trigger on-demand
2023-10-10 11:47:32 +02:00
Ilija Tovilo
92693a2286
Move Cirrus to nightly only, trigger on-demand
Closes GH-12398
2023-10-10 11:47:19 +02:00
Dmitry Stogov
70ff3c378d Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fixed possible use-after-free
2023-10-10 00:01:49 +03:00
Dmitry Stogov
2297e8c143 Fixed possible use-after-free 2023-10-10 00:01:03 +03:00
Niels Dossche
5e1058b426 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-8996: DOMNode serialization on PHP ^8.1
  Fix GH-12380: JIT+private array property access inside closure accesses private property in child class
2023-10-09 22:10:54 +02:00
Niels Dossche
24e5e4ec0d Fix GH-8996: DOMNode serialization on PHP ^8.1
PHP 8.1 introduced a seemingly unintentional BC break in ca94d55a19 by
blocking the (un)serialization of DOM objects.
This was done because the serialization never really worked and just
resulted in an empty object, which upon unserialization just resulted in
an object that you can't use.

Users can however implement their own serialization methods, but the
commit made that impossible as the ACC flag gets passed down to the
child class. An approach was tried in #10307 with a new ACC flag to
selectively allow serialization with subclasses if they implement the
right methods. However, that was found to be too ad hoc.

Instead, let's abuse how the __sleep and __wakeup methods work to throw
the exception instead. If the child class implements the __serialize /
__unserialize method, then the throwing methods won't be called.
Similarly, if the child class implements __sleep and __wakeup, then
they're overridden and it doesn't matter that they throw.

For the user, this PR has the exact same behaviour for (sub)classes that
don't implement the serialization methods: an exception will be thrown.
For code that previously implemented subclasses with these methods, this
approach will make that code work again. This approach should be both BC
preserving and unbreak user's code.

Closes GH-12388.

For the test:
Co-authored-by: wazelin <contact@sergeimikhailov.com>
2023-10-09 22:10:05 +02:00
Niels Dossche
fb6838770c Fix GH-12380: JIT+private array property access inside closure accesses private property in child class
For private fields, the scope has to be taken into account, otherwise
the property info may come from the wrong ce.

Closes GH-12381.
2023-10-09 22:10:05 +02:00
Dmitry Stogov
5a276bf478 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-12364: JIT leak in Symfony TranslationDebugCommandTest (#12394)
2023-10-09 23:07:39 +03:00
Dmitry Stogov
36b2c5dc88 Fix GH-12364: JIT leak in Symfony TranslationDebugCommandTest (#12394) 2023-10-09 23:07:34 +03:00
Dmitry Stogov
176b79fe7f Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect trace type inference
2023-10-09 22:58:21 +03:00
Dmitry Stogov
44a7016049 Fix incorrect trace type inference
Fixes GH-12365
2023-10-09 22:57:31 +03:00
Dmitry Stogov
b38c57b4fc Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fixed GH-12382: JIT Index invalid or out of range error
2023-10-09 11:20:36 +03:00
Dmitry Stogov
5a8f96b0bb Fixed GH-12382: JIT Index invalid or out of range error 2023-10-09 11:20:18 +03:00
Niels Dossche
325b2b4a56 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] Add xml and simplexml dependency to EXTENSIONS section in test
2023-10-07 21:13:47 +02:00
Niels Dossche
6bb536e3f6 [ci skip] Add xml and simplexml dependency to EXTENSIONS section in test 2023-10-07 21:13:30 +02:00
Niels Dossche
4268b0cdf8 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix Windows CI
2023-10-07 15:50:41 +02:00
Niels Dossche
ae52f1958d Fix Windows CI
The path to mysql.exe changed. Fortunately, chocolately puts the folder
containing the exe in the PATH environment variable, so we don't even
need to provide an absolute path.
2023-10-07 15:49:46 +02:00
Niels Dossche
a1845944ce Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  php_cli_server: ensure single date header is present
2023-10-06 17:50:13 +02:00
coppolafab
f6ac08c6a3 php_cli_server: ensure single date header is present
Currently the PHP Development Server appends a Date header in the
response, despite already set from user code.

Added a check condition before append the header, and a test file.

Closes GH-12363.
2023-10-06 17:49:30 +02:00
Ilija Tovilo
af5cdd8db0
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Minimal backport of 098d9ca
2023-10-04 15:33:25 +02:00
Ilija Tovilo
36a87e6d32
Minimal backport of 098d9ca 2023-10-04 15:31:04 +02:00
Ilija Tovilo
6f8261ed79
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix SKIPIF jit test
2023-10-04 15:06:32 +02:00
Ilija Tovilo
6e7e52de19
Fix SKIPIF jit test
JIT can be available but disabled, in which case the array offset 'jit' is still
available.
2023-10-04 15:05:41 +02:00
Ilija Tovilo
b13f743761
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [skip ci] Test opcache_invalidate() return value for deleted files
2023-10-03 15:56:16 +02:00
Ilija Tovilo
cad1660501
[skip ci] Test opcache_invalidate() return value for deleted files 2023-10-03 15:55:44 +02:00
Ilija Tovilo
6274970bee
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Invalidate path even if the file was deleted
2023-10-03 15:32:28 +02:00
Mikhail Galanin
f4ab494906
Invalidate path even if the file was deleted
Closes GH-12323
2023-10-03 15:31:39 +02:00
Dmitry Stogov
101bd1b199 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fixed GH-12262: Tracing JIT assertion crash when using phpstan
2023-10-03 13:25:22 +03:00
Dmitry Stogov
54452b4811 Fixed GH-12262: Tracing JIT assertion crash when using phpstan 2023-10-03 13:22:33 +03:00
Niels Dossche
6aa20956fb Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Ignore optional warning output in test
2023-10-02 22:55:28 +02:00
Niels Dossche
6cf76d552e Ignore optional warning output in test
Due to the greedy behaviour of regex, we can't seem to use %A?
Use a for loop with a marker instead to ignore module startup warnings.
2023-10-02 22:53:39 +02:00
Niels Dossche
87cd401aaf Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix test under older CI configurations
2023-10-02 21:52:52 +02:00
Niels Dossche
b140f6e9f8 Fix test under older CI configurations 2023-10-02 21:52:44 +02:00
Niels Dossche
28a909d40a Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix #80092: ZTS + preload = segfault on shutdown
2023-10-02 19:37:09 +02:00
Niels Dossche
bdc87b0f66 Fix #80092: ZTS + preload = segfault on shutdown
After preloading has executed, the executor globals for class_table and
function_table are still referring to the values during preloading.
If no request happens after that then these values will remain dangling
pointers. If then the -v option on CLI or -h option (and possibly
others) on CGI is provided, there is a double free.
Fix it by nulling the pointers explicitly after preloading has finished
to fix it for all SAPIs.

Closes GH-12311.
2023-10-02 19:33:41 +02:00
Anatol Belski
1934da0a81 NEWS: Added note about #11891
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2023-09-30 19:18:25 +02:00
Anatol Belski
e181af7018 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  NEWS: Added note about #11891
2023-09-30 19:17:36 +02:00
Anatol Belski
a1225f35bb NEWS: Added note about #11891
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2023-09-30 19:16:42 +02:00
Niels Dossche
77f44b2281 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Apply SimpleXML iterator fixes only on master
2023-09-30 17:53:57 +02:00
Niels Dossche
b842ea4fa8 Apply SimpleXML iterator fixes only on master
Many methods in SimpleXML reset the iterator when called. This has the
consequence that mixing these operations with loops can cause infinite
loops, or the loss of iteration data.
Some people may however rely on the resetting behaviour. To prevent
unintended breaks in stable branches, let's only apply the fix to master.

This reverts GH-12193, GH-12229, GG-12247 for stable branches while
keeping them on master, adding a note in UPGRADING as well.
2023-09-30 17:48:05 +02:00
Anatol Belski
4b22cb213a Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  fileinfo: Backport svg detection patch
2023-09-30 16:26:24 +02:00
usarise
1f5bea3452 fileinfo: Backport svg detection patch 2023-09-30 16:17:03 +02:00
Niels Dossche
0f5b382528 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Revert "Fix GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT"
2023-09-30 01:27:06 +02:00
Niels Dossche
643c4ba417 Revert "Fix GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT"
Although it passes CI on 8.1, it causes CI failures in the JIT on 8.2 and
higher.
See 1726922500

This reverts commit e72fc12058.
2023-09-30 01:25:48 +02:00
Niels Dossche
d7a7309b53 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT
  Fix type error on XSLTProcessor::transformToDoc return value with SimpleXML
2023-09-30 00:10:35 +02:00
Niels Dossche
e72fc12058 Fix GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT
This test triggers narrowing for two ops: first ZEND_ADD_ARRAY_ELEMENT,
and then ZEND_ASSIGN.

The type inference happens in the following order:
1) The ZEND_ADD_ARRAY_ELEMENT infers type 0x40e04080 (packed flag is set),
   arr_type=0 at this point because it hasn't been set by ZEND_INIT_ARRAY yet.
2) The ZEND_INIT_ARRAY infers type 0x40804080
3) The ZEND_ADD_ARRAY_ELEMENT infers type 0x40e04080, arr_type=0x40804080,
   which does not have the packed flag set while the existing result of
   ZEND_ADD_ARRAY_ELEMENT has the packed flag set.

This seems to occur because of the phi node introduced by the while
loop. If I remove the loop the problem goes away.

As Arnaud noted, this seems to be caused by a too wide type inference
for arr_type==0. We should keep the invariant that if x>=y then
key_type(x) >= key_type(y).
If we write the possible results down in a table we get:

```
arr_type           resulting key type
---------------    --------------------------------------------------------------------------
HASH_ONLY	-> MAY_BE_ARRAY_NUMERIC_HASH
PACKED_ONLY	-> MAY_BE_ARRAY_NUMERIC_HASH | MAY_BE_ARRAY_PACKED (== MAY_BE_ARRAY_KEY_LONG)
HASH || PACKED	-> MAY_BE_ARRAY_NUMERIC_HASH | MAY_BE_ARRAY_PACKED (== MAY_BE_ARRAY_KEY_LONG)
0		-> MAY_BE_ARRAY_NUMERIC_HASH | MAY_BE_ARRAY_PACKED (== MAY_BE_ARRAY_KEY_LONG)
```

As we can see, `HASH_ONLY > 0` but
`MAY_BE_ARRAY_NUMERIC_HASH < MAY_BE_ARRAY_NUMERIC_HASH | MAY_BE_ARRAY_PACKED`,
which violates the invariant.
Instead if we modify the zero case to have MAY_BE_ARRAY_NUMERIC_HASH instead,
we get the following table which satisfies the invariant.

```
arr_type           resulting key type
---------------    --------------------------------------------------------------------------
HASH_ONLY	-> MAY_BE_ARRAY_NUMERIC_HASH
PACKED_ONLY	-> MAY_BE_ARRAY_NUMERIC_HASH | MAY_BE_ARRAY_PACKED (== MAY_BE_ARRAY_KEY_LONG)
HASH || PACKED	-> MAY_BE_ARRAY_NUMERIC_HASH | MAY_BE_ARRAY_PACKED (== MAY_BE_ARRAY_KEY_LONG)
0		-> MAY_BE_ARRAY_NUMERIC_HASH
```

Broke in 1ffbb73.
Closes GH-10294.
2023-09-30 00:08:32 +02:00
Niels Dossche
2a7f23e9b9 Fix type error on XSLTProcessor::transformToDoc return value with SimpleXML
The return type is wrong. You can also use this method with SimpleXML.
In fact, PHP provides a way that even third party libraries can hook
into its XML handling. Therefore, we cannot even use the
SimpleXML|DOMDocument|false union type as third party extensions may
extend the possibilities.

Broke in 8.1 in 1b35056a33.

Closes GH-12315.
2023-09-30 00:03:42 +02:00
twosee
90707f33e1
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix socket_export_stream() with wrong protocol
2023-09-29 18:33:59 +08:00
twosee
b5da98b972
Fix socket_export_stream() with wrong protocol
Closes GH-12310.
2023-09-29 18:33:12 +08:00
Niels Dossche
19886d3af5 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Restore old namespace reconciliation behaviour
2023-09-27 22:33:45 +02:00