ndossche
74fad61607
Add test for array_diff() array maximum
...
Forgot to commit this in 614b22ab .
2026-03-21 22:58:49 +01:00
Jorg Adam Sowa
b58087daab
test: improve tests for in_array ( #21087 )
...
By splitting the massive tests into more specific, smaller tests.
2026-02-23 12:36:38 +00:00
Jorg Adam Sowa
6d95a2238d
ext/standard: validate mode in array_filter() ( #15647 )
...
And add the missing ARRAY_FILTER_USE_VALUE for the default case.
2026-01-26 16:02:15 +00:00
Ilija Tovilo
f4728ecc57
[skip ci] Move opcache.opt_debug_level tests to ext/opcache
...
These tests need to live in ext/opcache, or they will break the file cache job.
2026-01-21 16:53:57 +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
Jakub Zelenka
122a94ebe9
Merge branch 'PHP-8.5'
...
* PHP-8.5:
Update NEWS with info about security issues
Fix GHSA-www2-q4fc-65wf
Fix GHSA-h96m-rvf9-jgm2
Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
Fix GH-20584: Information Leak of Memory
2025-12-16 15:37:38 +01:00
Jakub Zelenka
5c0a6feca2
Merge branch 'PHP-8.4' into PHP-8.5
...
* PHP-8.4:
Update NEWS with info about security issues
Fix GHSA-www2-q4fc-65wf
Fix GHSA-h96m-rvf9-jgm2
Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
Fix GH-20584: Information Leak of Memory
2025-12-16 15:36:52 +01:00
Jakub Zelenka
633fb48fca
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Update NEWS with info about security issues
Fix GHSA-www2-q4fc-65wf
Fix GHSA-h96m-rvf9-jgm2
Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
Fix GH-20584: Information Leak of Memory
2025-12-16 15:35:25 +01:00
Jakub Zelenka
e776695abf
Merge branch 'PHP-8.2' into PHP-8.3
...
* PHP-8.2:
Update NEWS with info about security issues
Fix GHSA-www2-q4fc-65wf
Fix GHSA-h96m-rvf9-jgm2
Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
Fix GH-20584: Information Leak of Memory
2025-12-16 15:34:19 +01:00
Jakub Zelenka
6e124d0df6
Merge branch 'PHP-8.1' into PHP-8.2
...
* PHP-8.1:
Update NEWS with info about security issues
Fix GHSA-www2-q4fc-65wf
Fix GHSA-h96m-rvf9-jgm2
Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
Fix GH-20584: Information Leak of Memory
2025-12-16 15:30:54 +01:00
Niels Dossche
8b801151bd
Fix GHSA-h96m-rvf9-jgm2
2025-12-16 15:26:59 +01:00
Gina Peter Banyard
d026e2bca1
ext/standard/array.c: add tests when extracting negative keys
2025-11-19 20:41:48 +00:00
Niels Dossche
a0b918d3ee
Merge branch 'PHP-8.4' into PHP-8.5
...
* PHP-8.4:
Fix memory leak in array_diff() with custom type checks
2025-11-08 22:42:26 +01:00
Niels Dossche
43b232a654
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix memory leak in array_diff() with custom type checks
2025-11-08 22:42:11 +01:00
Niels Dossche
80b731659a
Fix memory leak in array_diff() with custom type checks
...
Closes GH-20428.
2025-11-08 22:41:44 +01:00
Gina Peter Banyard
9a1b8a785d
Fix GH-20194: null offset deprecation not emitted for writes ( #20238 )
...
Based on a patch from @ndossche
2025-10-29 18:36:10 +00:00
Alexandre Daubois
b40e479e39
Merge branch 'PHP-8.4' into PHP-8.5
...
* PHP-8.4:
Fix GH-19926: reset internal pointer earlier while splicing array while COW violation flag is still set (#19929 )
2025-10-06 16:53:45 +02:00
Alexandre Daubois
2cc4532865
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix GH-19926: reset internal pointer earlier while splicing array while COW violation flag is still set (#19929 )
2025-10-06 16:52:50 +02:00
Alexandre Daubois
64c1d43b68
Fix GH-19926: reset internal pointer earlier while splicing array while COW violation flag is still set ( #19929 )
2025-10-06 16:51:23 +02:00
Niels Dossche
1f809a55cf
Merge branch 'PHP-8.4' into PHP-8.5
...
* PHP-8.4:
Fix GH-20043: array_unique assertion failure with RC1 array causing an exception on sort
2025-10-05 20:16:12 +02:00
Niels Dossche
f2f84e36eb
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix GH-20043: array_unique assertion failure with RC1 array causing an exception on sort
2025-10-05 20:15:55 +02:00
Niels Dossche
4fed57e746
Fix GH-20043: array_unique assertion failure with RC1 array causing an exception on sort
...
The reason this happens is because the array_unique operation happens in-place
because the input array is RC1.
At one point during comparison an exception is thrown which will capture the
arguments in the backtrace, which will increment the refcount of the RC1 array
to 2. Then a modification happens after the throw on the RC2 array causing the
assertion failure.
We shouldn't try continue work after an exception happened during the sort.
Closes GH-20059.
2025-10-05 20:15:28 +02:00
Gina Peter Banyard
320fe2975b
core: Warn when coercing NAN to other types
...
RFC: https://wiki.php.net/rfc/warnings-php-8-5#coercing_nan_to_other_types
Closes GH-19573
2025-09-23 11:16:51 +01:00
Alexandre Daubois
49e3956b70
core: Deprecate using null as an array offset and when calling array_key_exists() ( #19511 )
...
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_using_values_null_as_an_array_offset_and_when_calling_array_key_exists
2025-09-04 22:12:24 +01:00
Gina Peter Banyard
cab46b27b9
ext/standard: Deprecate passing integers outside the interval [0, 255] to chr() ( #19441 )
...
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_integers_outside_the_interval_0_255_to_chr
2025-08-14 20:48:48 +01:00
Ilija Tovilo
fd8dfe1bfd
Merge branch 'PHP-8.4'
...
* PHP-8.4:
Fix GH-16649: Avoid UAF when using array_splice
2025-08-13 14:16:50 +02:00
Ilija Tovilo
7e01cf59bb
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix GH-16649: Avoid UAF when using array_splice
2025-08-13 14:16:12 +02:00
Alexandre Daubois
c8774f9e61
Fix GH-16649: Avoid UAF when using array_splice
...
Closes GH-19399
2025-08-13 14:15:34 +02:00
Gina Peter Banyard
1e0c8baf05
tree: drop non canonical casts and ZPP tests
2025-08-06 13:20:28 +01:00
Niels Dossche
cee8ed235a
Merge branch 'PHP-8.4'
...
* PHP-8.4:
Fix GH-19300: Nested array_multisort invocation with error breaks
2025-07-31 19:01:28 +02:00
Niels Dossche
b82c8ba7fe
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix GH-19300: Nested array_multisort invocation with error breaks
2025-07-31 19:01:13 +02:00
Niels Dossche
a96b05e63f
Fix GH-19300: Nested array_multisort invocation with error breaks
...
There are 2 issues:
1. When a MULTISORT_ABORT happens, it frees func, but func may point to
ARRAYG(multisort_func), which would be a problem with nested
invocations as it can destroy that of the "parent" invocation.
To solve this, delay assigning to the globals.
2. The old globals were not restored which means that nested invocations
with different flags will cause a wrong sorting function to be used.
Closes GH-19319.
2025-07-31 19:00:45 +02:00
Niels Dossche
be23be08dc
Merge branch 'PHP-8.4'
...
* PHP-8.4:
Fix RCN violations in array functions
2025-06-24 23:30:08 +02:00
Niels Dossche
f77c04d007
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix RCN violations in array functions
2025-06-24 23:29:50 +02:00
Niels Dossche
359a21f102
Fix RCN violations in array functions
...
When the array functions perform their operation in-place, the
`@refcount 1` annotation is wrong and causes a failure under
`ZEND_VERIFY_FUNC_INFO`.
The test file tests all functions that have the in-place optimization,
even those that didn't have the refcount annotation, just to prevent
future regressions.
Closes GH-18929.
2025-06-24 23:29:00 +02:00
Niels Dossche
168343d2e8
[RFC] Implement array_first() and array_last() ( #18210 )
2025-05-07 08:15:50 +02:00
David Carlier
e80d9535d7
Merge branch 'PHP-8.4'
2025-05-04 14:15:32 +01:00
David Carlier
2e2077172d
Merge branch 'PHP-8.3' into PHP-8.4
2025-05-04 14:15:05 +01:00
David Carlier
8a585856d1
Fix GH-18480: array_splice overflow on array length with offset.
...
close GH-18483
2025-05-04 14:14:22 +01:00
Gina Peter Banyard
2a859abd33
Remove test dependency on resource/object IDs
2025-03-13 15:00:07 +00:00
Niels Dossche
0dede83264
Merge branch 'PHP-8.4'
...
* PHP-8.4:
Fix memory leaks in array_any() / array_all()
2025-03-05 19:53:30 +01:00
Niels Dossche
75cca9f19e
Fix memory leaks in array_any() / array_all()
...
The return value is overwritten, but if the key was not an interned
string we should destroy it.
Closes GH-17977.
2025-03-05 19:52:16 +01:00
Niels Dossche
d0d8e6867a
Merge branch 'PHP-8.4'
...
* PHP-8.4:
Fix GH-17447: Assertion failure when array popping a self addressing variable
2025-01-16 20:29:08 +01:00
Niels Dossche
ae3ab37816
Fix GH-17447: Assertion failure when array popping a self addressing variable
...
This is the same bug as GH-16957, and fixed in the same way.
Closes GH-17448.
2025-01-16 20:28:51 +01:00
divinity76
47e440019c
improve range array overflow error message ( #16510 )
...
Improve range array overflow error message
Added info about "how much it exceeded" and the maximum allowable array size.
Makes debugging easier when encountering this specific issue.
2024-12-30 18:53:16 +01:00
Niels Dossche
563da1b9d2
Merge branch 'PHP-8.4'
...
* PHP-8.4:
Fix GH-16957: Assertion failure in array_shift with self-referencing array
2024-11-29 19:22:07 +01:00
Niels Dossche
ab7c3b1e7b
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix GH-16957: Assertion failure in array_shift with self-referencing array
2024-11-29 19:21:49 +01:00
Niels Dossche
f1fc4e8ff7
Fix GH-16957: Assertion failure in array_shift with self-referencing array
...
We have an RC1 violation because we're immediately dereferencing and
copying the resulting array in the test case. Instead, transfer the
lifetime using RETVAL_COPY_VALUE and unwrap only after the internal
iterator is reset.
Closes GH-16970.
2024-11-29 19:21:11 +01:00
Niels Dossche
c10f5ce9c1
Merge branch 'PHP-8.4'
...
* PHP-8.4:
Fix GH-16905: Internal iterator functions can't handle UNDEF properties
2024-11-28 19:23:02 +01:00
Niels Dossche
3a80936391
Merge branch 'PHP-8.3' into PHP-8.4
...
* PHP-8.3:
Fix GH-16905: Internal iterator functions can't handle UNDEF properties
2024-11-28 19:22:55 +01:00