[php-src] master: Merge branch 'PHP-8.5' into PHP-8.6

From: Date: Fri, 20 Nov 2026 11:16:41 +0000
Subject: [php-src] master: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143965@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Date: 2026-11-20T12:16:04+01:00 Commit: https://github.com/php/php-src/commit/c965bc5b36adbf7f6543f0debc13ada6c486bf0d Raw diff: https://github.com/php/php-src/commit/c965bc5b36adbf7f6543f0debc13ada6c486bf0d.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: SCCP: Fix constant propagation when unpacking into partial arrays (#25508) Changed paths: A ext/opcache/tests/opt/sccp_array_unpack_partial.phpt M NEWS M Zend/Optimizer/sccp.c Diff: diff --git a/NEWS b/NEWS index d9d78c77a230..4afe87b2d37f 100644 --- a/NEWS +++ b/NEWS @@ -120,6 +120,8 @@ PHP NEWS (pavimus) . Fixed opcache.enable_file_override lookups racing with OPcache restarts (pavimus) + . Fixed incorrect constant propagation when unpacking into partially known + arrays. (Weilin Du) - OpenSSL: . Fixed bug GH-25172 (TLS session reuse shares request-lifetime callback diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index 42dcb4629fa8..02cd1be3b56e 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -541,6 +541,9 @@ static inline zend_result ct_eval_add_array_unpack(zval *result, const zval *arr ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(array), key, value) { if (key) { value = zend_hash_update(Z_ARR_P(result), key, value); + } else if (IS_PARTIAL_ARRAY(result)) { + /* The next free index of a partial array is unknown. */ + continue; } else { value = zend_hash_next_index_insert(Z_ARR_P(result), value); } diff --git a/ext/opcache/tests/opt/sccp_array_unpack_partial.phpt b/ext/opcache/tests/opt/sccp_array_unpack_partial.phpt new file mode 100644 index 000000000000..0198ca263ea7 --- /dev/null +++ b/ext/opcache/tests/opt/sccp_array_unpack_partial.phpt @@ -0,0 +1,40 @@ +--TEST-- +SCCP must not infer numeric keys when unpacking into a partial array +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.jit=0 +--EXTENSIONS-- +opcache +--FILE-- +<?php +function test($unknown) { + $array = [$unknown, ...[42]]; + var_dump($array[0], $array[1]); + + $array = [10, $unknown, ...[42, 43]]; + var_dump($array[0], $array[1], $array[2], $array[3]); + + $array = [100 => $unknown, ...[42]]; + var_dump($array[0] ?? 'missing', $array[100], $array[101]); + + $array = [$unknown, 'key' => 0, ...[42, 'key' => 43], 44]; + var_dump($array[0], $array[1], $array[2], $array['key']); +} +test(7); +?> +--EXPECT-- +int(7) +int(42) +int(10) +int(7) +int(42) +int(43) +string(7) "missing" +int(7) +int(42) +int(7) +int(42) +int(44) +int(43)

« previous php.cvs (#143965) next »