Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4e562f4
ext/sockets: socket_recvfrom() add test for missing port argument err…
Girgias Oct 5, 2025
fd1c366
ext/sockets: socket_recvfrom() improve error message when port argume…
Girgias Oct 5, 2025
aed3acf
ext/opcache: add const qualifiers
Girgias Oct 3, 2025
1b651db
ext/opcache: use bool type instead of int
Girgias Oct 3, 2025
20a44af
ext/opcache: use zend_result type instead of int
Girgias Oct 3, 2025
e0a82b5
ext/opcache: use RETURN_BOOL() instead of if/else
Girgias Oct 3, 2025
cab2faa
ext/opcache/zend_accelerator_module.c: remove unused include
Girgias Oct 3, 2025
3abebf3
Fix JIT TLS on MacOS
arnaud-lb Oct 13, 2025
54d793d
Merge branch 'PHP-8.3' into PHP-8.4
arnaud-lb Oct 13, 2025
0f63407
Merge branch 'PHP-8.4' into PHP-8.5
arnaud-lb Oct 13, 2025
dc8b9f0
Merge branch 'PHP-8.5'
arnaud-lb Oct 13, 2025
8e0504c
Partially fix GH-16317: DOM classes do not allow __debugInfo() overri…
nielsdos Oct 11, 2025
39ef16a
Merge branch 'PHP-8.3' into PHP-8.4
nielsdos Oct 13, 2025
390e243
Add forgotten NEWS item
nielsdos Oct 13, 2025
599078f
Merge branch 'PHP-8.4' into PHP-8.5
nielsdos Oct 13, 2025
7fbf9b8
Merge branch 'PHP-8.5'
nielsdos Oct 13, 2025
3b54fa4
Make entry argument nullable for phar_split_fname() to avoid extra al…
nielsdos Oct 13, 2025
b529c77
phar: Fix more alias memory leaks
nielsdos Oct 12, 2025
5e58833
Merge branch 'PHP-8.3' into PHP-8.4
nielsdos Oct 13, 2025
5ce0019
Merge branch 'PHP-8.4' into PHP-8.5
nielsdos Oct 13, 2025
b9aa42e
Merge branch 'PHP-8.5'
nielsdos Oct 13, 2025
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
6 changes: 6 additions & 0 deletions ext/dom/php_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ static void dom_unset_property(zend_object *object, zend_string *member, void **
zend_std_unset_property(object, member, cache_slot);
}

/* This custom handler is necessary to avoid a recursive construction of the entire subtree. */
static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /* {{{ */
{
dom_object *obj = php_dom_obj_from_obj(object);
Expand All @@ -498,6 +499,11 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
dom_prop_handler *entry;
zend_string *object_str;

/* As we have a custom implementation, we must manually check for overrides. */
if (object->ce->__debugInfo) {
return zend_std_get_debug_info(object, is_temp);
}

*is_temp = 1;

std_props = zend_std_get_properties(object);
Expand Down
20 changes: 20 additions & 0 deletions ext/dom/tests/gh16317.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
GH-16317 (DOM classes do not allow __debugInfo() overrides to work)
--FILE--
<?php

class Demo extends DOMNode {
public function __construct() {}
public function __debugInfo(): array {
return ['x' => 'y'];
}
}

var_dump(new Demo());

?>
--EXPECT--
object(Demo)#1 (1) {
["x"]=>
string(1) "y"
}
48 changes: 44 additions & 4 deletions ext/opcache/jit/tls/zend_jit_tls_darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,36 @@

#include <stdint.h>
#include <unistd.h>
#include <mach-o/dyld.h>

TSRMLS_CACHE_EXTERN();

/* Thunk format used since dydl 1284 (approx. MacOS 15)
* https://github.com/apple-oss-distributions/dyld/blob/9307719dd8dc9b385daa412b03cfceb897b2b398/libdyld/ThreadLocalVariables.h#L146 */
#if defined(__x86_64__) || defined(__aarch64__)
struct TLV_Thunkv2
{
void* func;
uint32_t key;
uint32_t offset;
};
#else
struct TLV_Thunkv2
{
void* func;
uint16_t key;
uint16_t offset;
};
#endif

/* Thunk format used in earlier versions */
struct TLV_Thunkv1
{
void* func;
size_t key;
size_t offset;
};

zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
size_t *tcb_offset,
size_t *module_index,
Expand All @@ -37,12 +64,25 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
}

#if defined(__x86_64__)
size_t *ti;
struct TLV_Thunkv2 *thunk;
__asm__ __volatile__(
"leaq __tsrm_ls_cache(%%rip),%0"
: "=r" (ti));
*module_offset = ti[2];
*module_index = ti[1] * 8;
: "=r" (thunk));

/* Detect dyld 1284: With dyld 1284, thunk->func will be _tlv_get_addr.
* Unfortunately this symbol is private, but we can find it
* as _tlv_bootstrap+8: https://github.com/apple-oss-distributions/dyld/blob/9307719dd8dc9b385daa412b03cfceb897b2b398/libdyld/threadLocalHelpers.s#L54
* In earlier versions, thunk->func will be tlv_get_addr, which is not
* _tlv_bootstrap+8.
*/
if (thunk->func == (void*)((char*)_tlv_bootstrap + 8)) {
*module_offset = thunk->offset;
*module_index = (size_t)thunk->key * 8;
} else {
struct TLV_Thunkv1 *thunkv1 = (struct TLV_Thunkv1*) thunk;
*module_offset = thunkv1->offset;
*module_index = thunkv1->key * 8;
}

return SUCCESS;
#endif
Expand Down
8 changes: 4 additions & 4 deletions ext/opcache/zend_accelerator_blacklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void zend_accel_blacklist_shutdown(zend_blacklist *blacklist)
return;
}

zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos;
const zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos;
while (p<end) {
free(p->path);
p++;
Expand Down Expand Up @@ -336,10 +336,10 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename)
zend_accel_blacklist_update_regexp(blacklist);
}

bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len)
bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len)
{
int ret = 0;
zend_regexp_list *regexp_list_it = blacklist->regexp_list;
const zend_regexp_list *regexp_list_it = blacklist->regexp_list;
pcre2_match_context *mctx = php_pcre_mctx();

if (regexp_list_it == NULL) {
Expand All @@ -363,7 +363,7 @@ bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify
return ret;
}

void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument)
void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument)
{
int i;

Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/zend_accelerator_blacklist.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void zend_accel_blacklist_init(zend_blacklist *blacklist);
void zend_accel_blacklist_shutdown(zend_blacklist *blacklist);

void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename);
bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len);
void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument);
bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len);
void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument);

#endif /* ZEND_ACCELERATOR_BLACKLIST_H */
12 changes: 6 additions & 6 deletions ext/opcache/zend_accelerator_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, zend_
return entry;
}

static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_hash, zend_string *key, int data)
static zend_always_inline void* zend_accel_hash_find_ex(const zend_accel_hash *accel_hash, zend_string *key, bool data)
{
zend_ulong index;
zend_accel_hash_entry *entry;
Expand Down Expand Up @@ -176,20 +176,20 @@ static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_h
/* Returns the data associated with key on success
* Returns NULL if data doesn't exist
*/
void* zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key)
void* zend_accel_hash_find(const zend_accel_hash *accel_hash, zend_string *key)
{
return zend_accel_hash_find_ex(accel_hash, key, 1);
return zend_accel_hash_find_ex(accel_hash, key, true);
}

/* Returns the hash entry associated with key on success
* Returns NULL if it doesn't exist
*/
zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, zend_string *key)
zend_accel_hash_entry* zend_accel_hash_find_entry(const zend_accel_hash *accel_hash, zend_string *key)
{
return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, 0);
return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, false);
}

int zend_accel_hash_unlink(zend_accel_hash *accel_hash, zend_string *key)
zend_result zend_accel_hash_unlink(zend_accel_hash *accel_hash, zend_string *key)
{
zend_ulong hash_value;
zend_ulong index;
Expand Down
8 changes: 4 additions & 4 deletions ext/opcache/zend_accelerator_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ zend_accel_hash_entry* zend_accel_hash_update(
void *data);

void* zend_accel_hash_find(
zend_accel_hash *accel_hash,
const zend_accel_hash *accel_hash,
zend_string *key);

zend_accel_hash_entry* zend_accel_hash_find_entry(
zend_accel_hash *accel_hash,
const zend_accel_hash *accel_hash,
zend_string *key);

int zend_accel_hash_unlink(
zend_result zend_accel_hash_unlink(
zend_accel_hash *accel_hash,
zend_string *key);

static inline bool zend_accel_hash_is_full(zend_accel_hash *accel_hash)
static inline bool zend_accel_hash_is_full(const zend_accel_hash *accel_hash)
{
if (accel_hash->num_entries == accel_hash->max_num_entries) {
return true;
Expand Down
36 changes: 15 additions & 21 deletions ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "SAPI.h"
#include "zend_virtual_cwd.h"
#include "ext/standard/info.h"
#include "ext/standard/php_filestat.h"
#include "ext/date/php_date.h"
#include "opcache_arginfo.h"

Expand Down Expand Up @@ -62,7 +61,7 @@ static zif_handler orig_file_exists = NULL;
static zif_handler orig_is_file = NULL;
static zif_handler orig_is_readable = NULL;

static int validate_api_restriction(void)
static bool validate_api_restriction(void)
{
if (ZCG(accel_directives).restrict_api && *ZCG(accel_directives).restrict_api) {
size_t len = strlen(ZCG(accel_directives).restrict_api);
Expand All @@ -71,10 +70,10 @@ static int validate_api_restriction(void)
strlen(SG(request_info).path_translated) < len ||
memcmp(SG(request_info).path_translated, ZCG(accel_directives).restrict_api, len) != 0) {
zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " API is restricted by \"restrict_api\" configuration directive");
return 0;
return false;
}
}
return 1;
return true;
}

static ZEND_INI_MH(OnUpdateMemoryConsumption)
Expand Down Expand Up @@ -178,8 +177,8 @@ static ZEND_INI_MH(OnEnable)
}
return FAILURE;
} else {
*p = 0;
ZCG(accelerator_enabled) = 0;
*p = false;
ZCG(accelerator_enabled) = false;
return SUCCESS;
}
}
Expand Down Expand Up @@ -363,7 +362,7 @@ ZEND_INI_BEGIN()
#endif
ZEND_INI_END()

static int filename_is_in_cache(zend_string *filename)
static bool filename_is_in_cache(zend_string *filename)
{
zend_string *key;

Expand All @@ -373,27 +372,26 @@ static int filename_is_in_cache(zend_string *filename)
if (persistent_script && !persistent_script->corrupted) {
if (ZCG(accel_directives).validate_timestamps) {
zend_file_handle handle;
int ret;
bool ret;

zend_stream_init_filename_ex(&handle, filename);
ret = validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS
? 1 : 0;
ret = validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS;
zend_destroy_file_handle(&handle);
return ret;
}

return 1;
return true;
}
}

return 0;
return false;
}

static int filename_is_in_file_cache(zend_string *filename)
static bool filename_is_in_file_cache(zend_string *filename)
{
zend_string *realpath = zend_resolve_path(filename);
if (!realpath) {
return 0;
return false;
}

zend_file_handle handle;
Expand All @@ -406,7 +404,7 @@ static int filename_is_in_file_cache(zend_string *filename)
return result != NULL;
}

static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
static bool accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
{
if (ZEND_NUM_ARGS() == 1) {
zval *zv = ZEND_CALL_ARG(execute_data , 1);
Expand All @@ -415,7 +413,7 @@ static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
return filename_is_in_cache(Z_STR_P(zv));
}
}
return 0;
return false;
}

static ZEND_NAMED_FUNCTION(accel_file_exists)
Expand Down Expand Up @@ -947,11 +945,7 @@ ZEND_FUNCTION(opcache_invalidate)
RETURN_FALSE;
}

if (zend_accel_invalidate(script_name, force) == SUCCESS) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
RETURN_BOOL(zend_accel_invalidate(script_name, force) == SUCCESS);
}

/* {{{ Prevents JIT on function. Call it before the first invocation of the given function. */
Expand Down
Loading