Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1010592
sapi: Remove sapi_activate_headers_only (#24051)
NattyNarwhal Nov 27, 2026
04103df
Zend: Reset extended_value of FREE synthesized by DCE
iliaal Sep 25, 2026
7427db3
Merge branch 'PHP-8.4' into PHP-8.5
iliaal Nov 27, 2026
604eaea
ext/openssl: Fix SNI certs not used on streams sharing a session SSL_CTX
bukka Nov 27, 2026
63976d7
Merge branch 'PHP-8.6'
bukka Nov 27, 2026
fd55425
Merge branch 'PHP-8.5' into PHP-8.6
iliaal Nov 27, 2026
75c51c7
Merge branch 'PHP-8.6'
iliaal Nov 27, 2026
3dce06f
ext/pdo_dblib: Release persistent handle error strings at request end
iliaal Nov 2, 2026
b35fed7
Merge branch 'PHP-8.4' into PHP-8.5
iliaal Nov 27, 2026
c2ad51c
Merge branch 'PHP-8.5' into PHP-8.6
iliaal Nov 27, 2026
98fae34
Merge branch 'PHP-8.6'
iliaal Nov 27, 2026
cfe29b5
Fix stream context functions rejecting options held by reference (#25…
lacatoire Nov 28, 2026
5534bb7
Merge branch 'PHP-8.4' into PHP-8.5
LamentXU123 Nov 28, 2026
22d9227
ext/snmp: snmp_init_mib() crashes when $mibdirs is omitted or null
lazerg Nov 28, 2026
ad9dab7
Merge branch 'PHP-8.6'
devnexen Nov 28, 2026
a025125
Merge branch 'PHP-8.5' into PHP-8.6
LamentXU123 Nov 28, 2026
415f7b3
Merge branch 'PHP-8.6'
LamentXU123 Nov 28, 2026
972d667
ext/phar: phar_archive_delref() double free on shared archive at shut…
devnexen Nov 25, 2026
4257d50
Merge branch 'PHP-8.4' into PHP-8.5
devnexen Nov 28, 2026
5c957c5
Merge branch 'PHP-8.5' into PHP-8.6
devnexen Nov 28, 2026
aa5b88d
Merge branch 'PHP-8.6'
devnexen Nov 28, 2026
233f769
ext/sockets: Reject NUL bytes in ext/sockets host names (GH-25774)
jorgsowa Nov 28, 2026
4d426d1
Merge branch 'PHP-8.4' into PHP-8.5
jorgsowa Nov 28, 2026
c9ea441
Merge branch 'PHP-8.5' into PHP-8.6
jorgsowa Nov 28, 2026
43a7692
Merge branch 'PHP-8.6'
jorgsowa Nov 28, 2026
8096dc6
ext/standard: Release lc_needle on OOM in php_str_to_str_i_ex()
iliaal Nov 27, 2026
2ea1e46
Merge branch 'PHP-8.4' into PHP-8.5
iliaal Nov 28, 2026
a34414a
Merge branch 'PHP-8.5' into PHP-8.6
iliaal Nov 28, 2026
7a4a62b
Merge branch 'PHP-8.6'
iliaal Nov 28, 2026
16c4662
ext/opcache: Do not drop QM_ASSIGN of IS_VAR before ZEND_RETURN
iliaal Nov 26, 2026
e1fb101
Merge branch 'PHP-8.6'
iliaal Nov 28, 2026
4d09bb8
Zend: Accumulate parsed integer locally in _zend_handle_numeric_str_ex()
iliaal Nov 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ PHP 8.7 INTERNALS UPGRADE NOTES
. The sapi_get_fd() function was removed.
. The sapi_get_target_uid() function was removed.
. The sapi_get_target_gid() function was removed.
. The sapi_activate_headers_only() function was removed.
. Removed zend_hrtime_posix_clock_id. zend_hrtime() always uses
CLOCK_MONOTONIC on POSIX platforms.
. The INIT_CLASS_ENTRY_INIT_METHODS() macro, which was previously used as
Expand Down
2 changes: 1 addition & 1 deletion Zend/Optimizer/block_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
case ZEND_RETURN:
if (opline->op1_type == IS_TMP_VAR) {
src = VAR_SOURCE(opline->op1);
if (src && src->opcode == ZEND_QM_ASSIGN) {
if (src && src->opcode == ZEND_QM_ASSIGN && src->op1_type != IS_VAR) {
zend_op *op = src + 1;
bool optimize = true;

Expand Down
1 change: 1 addition & 0 deletions Zend/Optimizer/dce.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ static bool dce_instr(const context *ctx, zend_op *opline, zend_ssa_op *ssa_op)
opline->opcode = ZEND_FREE;
opline->op1.var = EX_NUM_TO_VAR(ssa->vars[free_var].var);
opline->op1_type = free_var_type;
opline->extended_value = 0;

ssa_op->op1_use = free_var;
ssa_op->op1_use_chain = ssa->vars[free_var].use_chain;
Expand Down
5 changes: 3 additions & 2 deletions Zend/zend_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -3490,10 +3490,11 @@ ZEND_ATTRIBUTE_NONNULL ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(c
*tmp > '2')) { /* overflow */
return 0;
}
*idx = (*tmp - '0');
zend_ulong val = *tmp - '0';
while (1) {
++tmp;
if (tmp == end) {
*idx = val;
if (*key == '-') {
if (*idx-1 > ZEND_LONG_MAX) { /* overflow */
return 0;
Expand All @@ -3505,7 +3506,7 @@ ZEND_ATTRIBUTE_NONNULL ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(c
return 1;
}
if (*tmp <= '9' && *tmp >= '0') {
*idx = (*idx * 10) + (*tmp - '0');
val = (val * 10) + (*tmp - '0');
} else {
return 0;
}
Expand Down
99 changes: 99 additions & 0 deletions ext/opcache/tests/gh25756.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
--TEST--
GH-25756 (OPcache: "Invalid opcode 62/4/0" when assigning a reference in a return)
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
--FILE--
<?php

function test_assign_ref() {
$b = 'success';
return $a = &$b;
}

function &get_ref() {
static $x = 'from_func';
return $x;
}

function test_assign_func_ref() {
return $a = &get_ref();
}

function test_assign_obj_ref(stdClass $obj, &$b) {
return $obj->p = &$b;
}

function test_assign_dim_ref() {
$b = 'dim_val';
$arr = [];
return $arr[0] = &$b;
}

class StaticPropHolder {
public static $p;
}

function test_assign_static_prop_ref(&$b) {
return StaticPropHolder::$p = &$b;
}

function test_list_by_ref() {
$arr = ['list_val'];
return [&$a] = $arr;
}

function test_ternary_assign_ref(bool $cond) {
$b = 'ternary_val';
return $cond ? ($a = &$b) : 'other';
}

function test_match_assign_ref(bool $cond) {
$b = 'match_val';
return match ($cond) {
true => $a = &$b,
default => 'other',
};
}

function test_typed_assign_ref(): string {
$b = 'typed_val';
return $a = &$b;
}

$obj = new stdClass();
$obj_src = 'obj_prop';
$obj_ret = test_assign_obj_ref($obj, $obj_src);
$obj_src = 'obj_changed';

$static_src = 'static_prop';
$static_ret = test_assign_static_prop_ref($static_src);
$static_src = 'static_changed';

$arrow_src = 'arrow_val';
$arrow = fn() => $a = &$arrow_src;

echo "1: ", test_assign_ref(), "\n";
echo "2: ", test_assign_func_ref(), "\n";
echo "3: ", $obj_ret, " / ", $obj->p, "\n";
echo "4: ", test_assign_dim_ref(), "\n";
echo "5: ", $static_ret, " / ", StaticPropHolder::$p, "\n";
echo "6: ", implode(',', test_list_by_ref()), "\n";
echo "7: ", test_ternary_assign_ref(true), "\n";
echo "8: ", test_match_assign_ref(true), "\n";
echo "9: ", test_typed_assign_ref(), "\n";
echo "10: ", $arrow(), "\n";
?>
--EXPECT--
1: success
2: from_func
3: obj_prop / obj_changed
4: dim_val
5: static_prop / static_changed
6: list_val
7: ternary_val
8: match_val
9: typed_val
10: arrow_val
51 changes: 51 additions & 0 deletions ext/opcache/tests/opt/dce_029.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--TEST--
DCE must not keep the replaced instruction's extended_value on a synthesized FREE
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.file_update_protection=0
opcache.jit=disable
--EXTENSIONS--
opcache
--FILE--
<?php
class D {
public function __destruct() {
throw new Exception("dtor");
}
}

final class C {
public array $a;

public function __construct() {
$this->a = [new D];
}

public function clobber(): int {
$this->a = [];
return 0;
}

public function test() {
empty(($this->a ?? [])[$this->clobber()]);
}
}

$c = new C;
try {
$c->test();
} catch (Exception $e) {
echo $e::class, ": ", $e->getMessage(), "\n";
}

$a = [];
for ($i = 0; $i < 10; $i++) {
$a[] = [$i];
}
echo count($a), "\n";
?>
--EXPECT--
Exception: dtor
10
78 changes: 78 additions & 0 deletions ext/openssl/tests/session_resumption_server_sni.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
--TEST--
Server SNI certificate selection on a stream seeded from a session stream
--EXTENSIONS--
openssl
--FILE--
<?php
$csFile = __DIR__ . DIRECTORY_SEPARATOR . 'session_resumption_server_sni_cs.pem.tmp';
$ukFile = __DIR__ . DIRECTORY_SEPARATOR . 'session_resumption_server_sni_uk.pem.tmp';
$usFile = __DIR__ . DIRECTORY_SEPARATOR . 'session_resumption_server_sni_us.pem.tmp';

include 'CertificateGenerator.inc';
$certificateGenerator = new CertificateGenerator();
$certificateGenerator->saveNewCertAsFileWithKey('cs.php.net', $csFile);
$certificateGenerator->saveNewCertAsFileWithKey('uk.php.net', $ukFile);
$certificateGenerator->saveNewCertAsFileWithKey('us.php.net', $usFile);

$server = stream_socket_server('tcp://127.0.0.1:0');
$addr = stream_socket_get_name($server, false);

function handshake(string $addr, $server, string $peerName, $session, array $serverOptions = []): array
{
$client = stream_socket_client("tcp://$addr", $errno, $errstr, 5, STREAM_CLIENT_CONNECT,
stream_context_create(['ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'capture_peer_cert' => true,
'peer_name' => $peerName,
]]));
$accepted = stream_socket_accept($server);
if ($serverOptions) {
stream_context_set_options($accepted, ['ssl' => $serverOptions]);
}
stream_set_blocking($client, false);
stream_set_blocking($accepted, false);

$clientDone = $serverDone = 0;
for ($i = 0; $i < 1000 && ($clientDone !== true || $serverDone !== true); $i++) {
if ($clientDone !== true) {
$clientDone = stream_socket_enable_crypto($client, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
}
if ($serverDone !== true) {
$serverDone = stream_socket_enable_crypto($accepted, true, STREAM_CRYPTO_METHOD_TLS_SERVER, $session);
}
usleep(1000);
}

$cert = stream_context_get_options($client)['ssl']['peer_certificate'];
var_dump(openssl_x509_parse($cert)['subject']['CN']);

return [$accepted, $client];
}

$parent = handshake($addr, $server, 'uk.php.net', null, [
'local_cert' => $csFile,
'SNI_server_certs' => [
'cs.php.net' => $csFile,
'uk.php.net' => $ukFile,
'us.php.net' => $usFile,
],
]);
$child = handshake($addr, $server, 'us.php.net', $parent[0]);

fclose($parent[0]);
fclose($parent[1]);
unset($parent);

$grandchild = handshake($addr, $server, 'uk.php.net', $child[0]);
?>
--CLEAN--
<?php
@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'session_resumption_server_sni_cs.pem.tmp');
@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'session_resumption_server_sni_uk.pem.tmp');
@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'session_resumption_server_sni_us.pem.tmp');
?>
--EXPECT--
string(10) "uk.php.net"
string(10) "us.php.net"
string(10) "uk.php.net"
30 changes: 30 additions & 0 deletions ext/openssl/xp_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,33 @@ static zend_result php_openssl_enable_server_sni(
return SUCCESS;
}

static void php_openssl_share_server_sni(php_stream *stream, php_openssl_netstream_data_t *sslsock,
const php_openssl_netstream_data_t *parent_sslsock)
{
if (sslsock->sni_certs || !parent_sslsock->sni_certs || !parent_sslsock->sni_cert_count) {
return;
}

bool persistent = php_stream_is_persistent(stream);
unsigned count = 0;

sslsock->sni_certs = safe_pemalloc(parent_sslsock->sni_cert_count,
sizeof(php_openssl_sni_cert_t), 0, persistent);

for (unsigned i = 0; i < parent_sslsock->sni_cert_count; i++) {
const php_openssl_sni_cert_t *parent_cert = &parent_sslsock->sni_certs[i];
if (!parent_cert->ctx) {
continue;
}
SSL_CTX_up_ref(parent_cert->ctx);
sslsock->sni_certs[count].ctx = parent_cert->ctx;
sslsock->sni_certs[count].name = pestrdup(parent_cert->name, persistent);
count++;
}

sslsock->sni_cert_count = count;
}

static void php_openssl_enable_client_sni(php_stream *stream, php_openssl_netstream_data_t *sslsock) /* {{{ */
{
zval *val;
Expand Down Expand Up @@ -2860,6 +2887,9 @@ static zend_result php_openssl_setup_crypto(php_stream *stream,
}

SSL_set_ex_data(sslsock->ssl_handle, php_openssl_get_ssl_stream_data_index(), stream);
#ifdef HAVE_TLS_SNI
php_openssl_share_server_sni(stream, sslsock, parent_sslsock);
#endif

if (!SSL_set_fd(sslsock->ssl_handle, sslsock->s.socket)) {
php_openssl_handle_ssl_error(stream, 0, true);
Expand Down
11 changes: 10 additions & 1 deletion ext/pdo_dblib/dblib_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ static void dblib_handle_closer(pdo_dbh_t *dbh)
}
}

static void dblib_handle_request_shutdown(pdo_dbh_t *dbh)
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;

if (H && dbh->refcount <= 2) {
pdo_dblib_err_dtor(&H->err);
}
}

static bool dblib_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, pdo_stmt_t *stmt, zval *driver_options)
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
Expand Down Expand Up @@ -454,7 +463,7 @@ static const struct pdo_dbh_methods dblib_methods = {
dblib_get_attribute, /* get attr */
dblib_handle_check_liveness, /* check_liveness */
NULL, /* get driver methods */
NULL, /* request shutdown */
dblib_handle_request_shutdown,
NULL, /* in transaction, use PDO's internal tracking mechanism */
NULL, /* get gc */
NULL /* scanner */
Expand Down
44 changes: 44 additions & 0 deletions ext/pdo_dblib/tests/persistent_error_state_across_requests.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--TEST--
PDO_DBLIB: Persistent handle error state does not outlive the request
--EXTENSIONS--
pdo_dblib
--SKIPIF--
<?php
require __DIR__ . '/config.inc';
getDbConnection();
?>
--ENV--
USE_ZEND_ALLOC=0
USE_TRACKED_ALLOC=1
--FILE--
<?php
require __DIR__ . '/../../../sapi/cli/tests/php_cli_server.inc';

$code = sprintf(<<<'PHP'
require %s;
[$dsn, $user, $pass] = getCredentials();
$db = new PDO($dsn, $user, $pass, [PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT]);
$stmt = $db->prepare('SELECT 1');
$stmt->execute();
var_dump($stmt->fetchColumn());
$db->exec('SELECT * FROM ' . $_GET['table']);
echo $db->errorInfo()[2], "\n";
PHP, var_export(__DIR__ . '/config.inc', true));

$args = [];
foreach (['pdo', 'pdo_dblib'] as $ext) {
if (file_exists(ini_get('extension_dir') . '/' . $ext . '.' . PHP_SHLIB_SUFFIX)) {
$args[] = '-dextension=' . ini_get('extension_dir') . '/' . $ext . '.' . PHP_SHLIB_SUFFIX;
}
}
php_cli_server_start($code, null, $args);

foreach (['pdo_dblib_missing_first', 'pdo_dblib_missing_second'] as $table) {
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/index.php?table=' . $table);
}
?>
--EXPECTF--
int(1)
Invalid object name 'pdo_dblib_missing_first'. [%d] (severity %d) []
int(1)
Invalid object name 'pdo_dblib_missing_second'. [%d] (severity %d) []
Loading
Loading