1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

5437 Commits

Author SHA1 Message Date
Ilija Tovilo
cb8d3a27c3 Merge branch 'PHP-8.5'
* PHP-8.5:
  [skip ci] Harden bug74093.phpt
2026-03-22 01:56:48 +01:00
Ilija Tovilo
b0215e9c1b Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  [skip ci] Harden bug74093.phpt
2026-03-22 01:56:44 +01:00
Ilija Tovilo
c52cfaf88b Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Harden bug74093.phpt
2026-03-22 01:56:38 +01:00
Ilija Tovilo
bc8a95e4fb Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Harden bug74093.phpt
2026-03-22 01:56:32 +01:00
Ilija Tovilo
486c09cd68 [skip ci] Harden bug74093.phpt
Rarely fails with "Maximum execution time of 1 seconds exceeded" due to being
too fast. Increase the compared arrays and mark as FLAKY, given this is
inherently dependent on processing speed.
2026-03-22 01:54:55 +01:00
Arnaud Le Blanc
2e20074310 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-20875: Propagate IN_GET guard in get_property_ptr_ptr for lazy proxies
2026-03-20 15:45:55 +01:00
Arnaud Le Blanc
5485f8ee40 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-20875: Propagate IN_GET guard in get_property_ptr_ptr for lazy proxies
2026-03-20 15:45:42 +01:00
Ilia Alshanetsky
9ec303edde Fix GH-20875: Propagate IN_GET guard in get_property_ptr_ptr for lazy proxies
zend_std_get_property_ptr_ptr() was the only property handler that did
not propagate the IN_GET guard to the underlying object when forwarding
from a lazy proxy after initialization. This caused __get to be called
on the underlying object when it shouldn't be, leading to assertion
failures.

The same guard-copying pattern already existed in read_property,
write_property, unset_property, and has_property since commit
26f5009e91 (GH-18039).

Also fixes GH-20873 and GH-20854.

Closes GH-20875
2026-03-20 15:44:21 +01:00
Gina Peter Banyard
f93b17076a Zend: inherit interfaces early (#18622)
The primary motivation for this is that this is required for my abstract generic types proof of concept, as the resolving of bound types needs to happen early to properly track the types.

However, there doesn't seem to be a good reason for delaying the inheritance of interfaces.
This approach might even allow us to drop the `iface` parameter of the `interface_gets_implemented()` handler as the interface name is always known.
2026-03-09 21:57:50 +00:00
Ilija Tovilo
cccc54872a Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix incorrect property_info sizing for locally shadowed trait properties
2026-03-09 13:50:59 +01:00
Ilija Tovilo
ff3f59b5a7 Fix incorrect property_info sizing for locally shadowed trait properties
Previously, static trait properties would always redeclare locally declared
static properties to make sure any inherited property would stop sharing a
common slot with the parent. This would leave holes in property_info, creating
issues for this code:

    zend_hash_extend(&ce->properties_info,
        zend_hash_num_elements(&ce->properties_info) +
        zend_hash_num_elements(&parent_ce->properties_info), 0);

where zend_hash_num_elements(&ce->properties_info) +
zend_hash_num_elements(&parent_ce->properties_info) is supposed to extend the
hash table enough to hold all additional properties coming from parent. However,
if ce->properties_info contains holes this might not be enough, given all parent
properties are appended at nNumUsed.

This could be fixed by further extending the hash table, but we can also avoid
the holes in properties_info completely by not redeclaring trait properties that
are already declared in the target class. This is now possible because traits
are bound before performing parent class inheritance, so if the property is
already present we know it will separate the property slot.

Fixes GH-20672
Closes GH-21358
2026-03-09 13:50:27 +01:00
Petr Sumbera
ce1cadba29 Fix Solaris tests and add nightly CI job
Closes GH-20709
2026-03-04 10:12:03 +01:00
Ilija Tovilo
073dcf66bb Merge branch 'PHP-8.5'
* PHP-8.5:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:05:28 +01:00
Ilija Tovilo
07e29acbd4 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:05:21 +01:00
Ilija Tovilo
6f91209260 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:05:14 +01:00
Ilija Tovilo
c6ad84fb9e Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:04:24 +01:00
Ilija Tovilo
3a57b4ced5 Add RUN_RESOURCE_HEAVY_TESTS env var
Disable resource-heavy tests by default (>1GB of memory usage), unless the
RUN_RESOURCE_HEAVY_TESTS env variable is set.

Fixes GH-20762
Closes GH-20935
2026-02-27 15:00:35 +01:00
Ilija Tovilo
fcb50e4d62 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix OSS-Fuzz #478009707 for JIT
2026-02-08 16:47:06 +01:00
Ilija Tovilo
ba6df41144 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix OSS-Fuzz #478009707 for JIT
2026-02-08 16:46:52 +01:00
Ilija Tovilo
bbde9c8178 Fix OSS-Fuzz #478009707 for JIT
This issue was already fixed in GH-21124, but some JIT paths were missing.

Closes GH-21151
2026-02-08 16:46:08 +01:00
Ilija Tovilo
984f95ffc1 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix assign-op/inc/dec on untyped hooked property backing value
2026-02-05 14:48:21 +01:00
Ilija Tovilo
f9df448bab Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix assign-op/inc/dec on untyped hooked property backing value
2026-02-05 14:48:15 +01:00
Ilija Tovilo
3cb85cc681 Fix assign-op/inc/dec on untyped hooked property backing value
Fixes OSS-Fuzz #478009707
Closes GH-21124
2026-02-05 14:46:06 +01:00
Ilija Tovilo
27d28eef1e Fix mistakenly allowed assignment to assignment through list operator (GH-21123)
Fixes OSS-Fuzz #480111866
Introduced in GH-20628
2026-02-04 01:47:01 +01:00
Ilija Tovilo
4188c3ee2c Fix missing deref in zend_fe_fetch_object_helper (GH-21116)
Fixes OSS-Fuzz #481017027
Introduced in GH-20628
2026-02-03 13:55:49 +01:00
Arnaud Le Blanc
4a1cca7ddc Revert lazy proxy state after failed initialization
We don't expect the lazy proxy to be modified during initialization, but
this is allowed. The modification may set a property, still marked LAZY,
without removing the LAZY flag. This causes an assertion failure in GH-20174.

Both the RFC and the documentation specify that after an initialization
failure, the state of the object is reset to its pre-initialization state:

    If the initializer throws an exception, the object state is reverted to
    its pre-initialization state and the object is marked as lazy again. In
    other words, all effects on the object itself are reverted. Other side
    effects, such as effects on other objects, are not reverted. This prevents
    exposing a partially initialized instance in case of failure.

This behavior would have prevented this issue, but it was not implemented
for lazy proxies (only for ghosts).

Fix by implementing the missing behavior.

Fixes GH-20174
Closes GH-20181
2026-02-03 12:12:03 +01:00
Arnaud Le Blanc
39f5ed943d Merge branch 'PHP-8.5'
* PHP-8.5:
  Real instance of lazy proxy may have less magic methods
2026-02-03 12:05:22 +01:00
Arnaud Le Blanc
83056c806c Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Real instance of lazy proxy may have less magic methods
2026-02-03 12:05:11 +01:00
Arnaud Le Blanc
de26827275 Real instance of lazy proxy may have less magic methods
In GH-18039 we guard the underlying property before forwarding access
to the real instance of a lazy proxy. When the real instance lacks magic
methods, the assertion zobj->ce->ce_flags & ZEND_ACC_USE_GUARDS fails in
zend_get_property_guard().

Fix by checking that the real instance uses guards.

Fixes GH-20504
Closes GH-21093
2026-02-03 12:04:35 +01:00
Arnaud Le Blanc
4810af9aac Merge branch 'PHP-8.5'
* PHP-8.5:
  Mark object non-lazy before deleting info in zend_lazy_object_realize()
2026-02-03 11:52:53 +01:00
Arnaud Le Blanc
1e81a9efc7 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Mark object non-lazy before deleting info in zend_lazy_object_realize()
2026-02-03 11:50:32 +01:00
Arnaud Le Blanc
6d6d013d79 Mark object non-lazy before deleting info in zend_lazy_object_realize()
A lazy object is marked non-lazy when all its properties are
initialized. Before doing so we delete the object info, resulting in a
temporarily invalid state. In GH-20657 the GC is triggered at this moment.

Fix by deleting the object info _after_ marking it non lazy.

Fixes GH-20657
Closes GH-21094
2026-02-03 11:48:36 +01:00
Ilija Tovilo
a01a8e72ac Fix failed assertion for assignment in expression context
This code path is reachable for all assignments expressions, not just true
variable expressions.

Really surprising we have no tests that caught this.
2026-02-01 14:14:08 +01:00
Ilija Tovilo
6173a9a109 VAR|TMP overhaul (GH-20628)
The aim of this PR is twofold:

- Reduce the number of highly similar TMP|VAR handlers
- Avoid ZVAL_DEREF in most of these cases

This is achieved by guaranteeing that all zend_compile_expr() calls, as well as
all other compile calls with BP_VAR_{R,IS}, will result in a TMP variable. This
implies that the result will not contain an IS_INDIRECT or IS_REFERENCE value,
which was mostly already the case, with two exceptions:

- Calls to return-by-reference functions. Because return-by-reference functions
  are quite rare, this is solved by delegating the DEREF to the RETURN_BY_REF
  handler, which will examine the stack to check whether the caller expects a
  VAR or TMP to understand whether the DEREF is needed. Internal functions will
  also need to adjust by calling the zend_return_unwrap_ref() function.

- By-reference assignments, including both $a = &$b, as well as $a = [&$b]. When
  the result of these expressions is used in a BP_VAR_R context, the reference
  is unwrapped via a ZEND_QM_ASSIGN opcode beforehand. This is exceptionally
  rare.

Closes GH-20628
2026-01-31 19:44:56 +01:00
Ilija Tovilo
0dd1bdc3e5 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix crash on (unset) cast in constant expression
2026-01-29 17:00:43 +01:00
arshidkv12
e9ae040629 Fix crash on (unset) cast in constant expression
Fixes GH-21072
Closes GH-21073
2026-01-29 17:00:06 +01:00
Jorg Adam Sowa
9f774e3a85 chore: improve errror message when passing named parameter for variadic in unsupported internal functions (#21012) 2026-01-25 18:27:57 +00:00
Ilija Tovilo
645e62bdde Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix hooked object properties overflow
2026-01-21 18:54:37 +01:00
Ilija Tovilo
6d02e51acb Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix hooked object properties overflow
2026-01-21 18:54:29 +01:00
Niels Dossche
d9cbc3117c Fix hooked object properties overflow
The computed number of properties using zend_hash_num_elements(zobj->properties)
is incorrect when the object contains virtual properties. We don't have a
trivial way to find the number of properties virtual properties that need to be
added to this number, so just append with zend_hash_add_new() instead.

Fixes GH-20479
Closes GH-20988
2026-01-21 18:53:41 +01:00
ndossche
8776c7ead1 Extend zend_test internal function handler to also print leave (with return info if requested) and exception state 2026-01-20 21:12:06 +01:00
Ilija Tovilo
51a3798ee4 Merge branch 'PHP-8.5'
* PHP-8.5:
  [skip ci] Fix missing test attribution
2026-01-20 18:01:15 +01:00
Ilija Tovilo
0e003a1d19 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  [skip ci] Fix missing test attribution
2026-01-20 18:01:10 +01:00
Ilija Tovilo
6a21a41b4a [skip ci] Fix missing test attribution 2026-01-20 18:00:58 +01:00
Ilija Tovilo
50d4f851d4 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix lazy proxy bailing __clone assertion
2026-01-20 17:59:28 +01:00
Ilija Tovilo
005242f8bd Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix lazy proxy bailing __clone assertion
2026-01-20 17:59:23 +01:00
Ilija Tovilo
f38f74521b Fix lazy proxy bailing __clone assertion
When __clone of the underlying object fails with a bailout, ZEND_ASSERT(res ==
SUCCESS) in zend_lazy_object_del_info() will fail because the info has not been
registered yet.

Only copy OBJ_EXTRA_FLAGS once the info has been successfully registered.

Fixes GH-20905
Closes GH-20975
2026-01-20 17:58:56 +01:00
Tim Düsterhus
a3576bddc5 zend_compile: Optimize array_map() with callable convert callback into foreach (#20934)
* zend_compile: Optimize `array_map()` with callable convert callback into foreach

For:

    <?php

    function plus1($x) {
    	return $x + 1;
    }

    $array = array_fill(0, 100, 1);

    $count = 0;
    for ($i = 0; $i < 100_000; $i++) {
    	$count += count(array_map(plus1(...), $array));
    }

    var_dump($count);

This is ~1.1× faster:

    Benchmark 1: /tmp/test/before -d opcache.enable_cli=1 /tmp/test/test6.php
      Time (mean ± σ):     172.2 ms ±   0.5 ms    [User: 167.8 ms, System: 4.2 ms]
      Range (min … max):   171.6 ms … 173.1 ms    17 runs

    Benchmark 2: /tmp/test/after -d opcache.enable_cli=1 /tmp/test/test6.php
      Time (mean ± σ):     155.1 ms ±   1.3 ms    [User: 150.6 ms, System: 4.2 ms]
      Range (min … max):   154.2 ms … 159.3 ms    18 runs

    Summary
      /tmp/test/after -d opcache.enable_cli=1 /tmp/test/test6.php ran
        1.11 ± 0.01 times faster than /tmp/test/before -d opcache.enable_cli=1 /tmp/test/test6.php

With JIT it becomes ~1.7× faster:

    Benchmark 1: /tmp/test/before -d opcache.enable_cli=1 -d opcache.jit=tracing /tmp/test/test6.php
      Time (mean ± σ):     166.9 ms ±   0.6 ms    [User: 162.7 ms, System: 4.1 ms]
      Range (min … max):   166.1 ms … 167.9 ms    17 runs

    Benchmark 2: /tmp/test/after -d opcache.enable_cli=1 -d opcache.jit=tracing /tmp/test/test6.php
      Time (mean ± σ):      94.5 ms ±   2.7 ms    [User: 90.4 ms, System: 3.9 ms]
      Range (min … max):    92.5 ms … 103.1 ms    31 runs

    Summary
      /tmp/test/after -d opcache.enable_cli=1 -d opcache.jit=tracing /tmp/test/test6.php ran
        1.77 ± 0.05 times faster than /tmp/test/before -d opcache.enable_cli=1 -d opcache.jit=tracing /tmp/test/test6.php

* zend_compile: Skip `assert(...)` callbacks for array_map() optimization

* zend_compile: Remove `zend_eval_const_expr()` in array_map optimization

* zend_vm_def: Check simple types without loading the arginfo in ZEND_TYPE_ASSERT

* zend_vm_def: Handle references for ZEND_TYPE_ASSERT

* zend_compile: Fix handling of constant arrays for `array_map()`

* zend_compile: Fix leak of unused result in array_map() optimization

* zend_compile: Support static methods for `array_map()` optimization

* UPGRADING
2026-01-19 10:18:24 +01:00
Ilija Tovilo
084e409694 Remove zend_exception_save() and zend_exception_restore()
These are leftovers from the pre-PHP-7.0 era. This also implicitly solves
GH-20564 by not clearing exceptions before entering the autoloader.

Closes GH-20256
Fixes GH-20564
2026-01-16 20:18:51 +01:00
Ilija Tovilo
8b4ef3a09f Fix FETCH_OBJ_UNSET IS_UNDEF result
UNSET_OBJ et al. do not expect to find IS_UNDEF results for IS_INDIRECT vars. To
solve this, return IS_NULL from FETCH_OBJ_UNSET when properties are
uninitialized. Do the same for FETCH_STATIC_PROP_IS, as we're otherwise copying
IS_UNDEF into the VAR result, which is not a valid value for VAR.

Fixes OSS-Fuzz #429429090
Closes GH-19160
2026-01-16 19:27:21 +01:00