Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ PHP NEWS
. Fixed bug GH-20217 (ReflectionClass::isIterable() incorrectly returns true
for classes with property hooks). (alexandre-daubois)

- Session:
. Fixed bug 71162 (updateTimestamp never called when session data is empty).
(Girgias)

- Soap:
. Soap::__setCookie() when cookie name is a digit is now not stored and
represented as a string anymore but a int. (David Carlier)
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ PHP 8.6 UPGRADE NOTES
- Session:
. A ValueError is not thrown if $name is a string containing null bytes in
session_module_name().
. session_encode() now returns an empty string instead of false for empty
sessions. It only returns false now when the session data could not be
encoded. This mainly happens with the default serialization handler
if a key contains the pipe | character.

- Standard:
. Invalid mode values now throw in array_filter() instead of being silently
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ PHP 8.6 INTERNALS UPGRADE NOTES
zend_string* parameter.
. EG(in_autoload) was renamed to EG(autoload_current_classnames) and no
longer is a pointer, but a directly embedded HashTable struct.
. Added a C23_ENUM() helper macro to define forward-compatible fixed-size
enums.

========================
2. Build system changes
Expand Down
20 changes: 11 additions & 9 deletions Zend/zend_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,12 @@ typedef struct _zend_class_constant {

#define ZEND_CLASS_CONST_FLAGS(c) Z_CONSTANT_FLAGS((c)->value)

C23_ENUM(zend_function_type, uint8_t) {
ZEND_INTERNAL_FUNCTION = 1,
ZEND_USER_FUNCTION = 2,
ZEND_EVAL_CODE = 4,
};

/* arg_info for internal functions */
typedef struct _zend_internal_arg_info {
const char *name;
Expand Down Expand Up @@ -524,7 +530,7 @@ typedef struct _zend_internal_function_info {

struct _zend_op_array {
/* Common elements */
uint8_t type;
zend_function_type type;
uint8_t arg_flags[3]; /* bitset of arg_info.pass_by_reference */
uint32_t fn_flags;
zend_string *function_name;
Expand Down Expand Up @@ -584,7 +590,7 @@ typedef void (ZEND_FASTCALL *zif_handler)(INTERNAL_FUNCTION_PARAMETERS);

typedef struct _zend_internal_function {
/* Common elements */
uint8_t type;
zend_function_type type;
uint8_t arg_flags[3]; /* bitset of arg_info.pass_by_reference */
uint32_t fn_flags;
zend_string* function_name;
Expand All @@ -610,11 +616,11 @@ typedef struct _zend_internal_function {
#define ZEND_FN_SCOPE_NAME(function) ((function) && (function)->common.scope ? ZSTR_VAL((function)->common.scope->name) : "")

union _zend_function {
uint8_t type; /* MUST be the first element of this struct! */
zend_function_type type; /* MUST be the first element of this struct! */
uint32_t quick_arg_flags;

struct {
uint8_t type; /* never used */
zend_function_type type; /* never used */
uint8_t arg_flags[3]; /* bitset of arg_info.pass_by_reference */
uint32_t fn_flags;
zend_string *function_name;
Expand Down Expand Up @@ -956,7 +962,7 @@ ZEND_API zend_ast *zend_compile_string_to_ast(
ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count, ...);
ZEND_API zend_result zend_execute_script(int type, zval *retval, zend_file_handle *file_handle);
ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle);
ZEND_API void init_op_array(zend_op_array *op_array, uint8_t type, int initial_ops_size);
ZEND_API void init_op_array(zend_op_array *op_array, zend_function_type type, int initial_ops_size);
ZEND_API void destroy_op_array(zend_op_array *op_array);
ZEND_API void zend_destroy_static_vars(zend_op_array *op_array);
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle);
Expand Down Expand Up @@ -1071,10 +1077,6 @@ ZEND_API zend_string *zend_type_to_string(zend_type type);
#define BP_VAR_FUNC_ARG 4
#define BP_VAR_UNSET 5

#define ZEND_INTERNAL_FUNCTION 1
#define ZEND_USER_FUNCTION 2
#define ZEND_EVAL_CODE 4

#define ZEND_USER_CODE(type) ((type) != ZEND_INTERNAL_FUNCTION)

#define ZEND_INTERNAL_CLASS 1
Expand Down
91 changes: 42 additions & 49 deletions Zend/zend_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static inline bool zend_is_whitespace(char c) {
*/
static int zend_remove_ini_entries(zval *el, void *arg) /* {{{ */
{
zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
const zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
int module_number = *(int *)arg;

return ini_entry->module_number == module_number;
Expand Down Expand Up @@ -70,9 +70,9 @@ static zend_result zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stag
}
ini_entry->value = ini_entry->orig_value;
ini_entry->modifiable = ini_entry->orig_modifiable;
ini_entry->modified = 0;
ini_entry->modified = false;
ini_entry->orig_value = NULL;
ini_entry->orig_modifiable = 0;
ini_entry->orig_modifiable = false;
}
return SUCCESS;
}
Expand All @@ -82,12 +82,12 @@ static void free_ini_entry(zval *zv) /* {{{ */
{
zend_ini_entry *entry = (zend_ini_entry*)Z_PTR_P(zv);

zend_string_release_ex(entry->name, 1);
zend_string_release_ex(entry->name, true);
if (entry->value) {
zend_string_release(entry->value);
}
if (entry->orig_value) {
zend_string_release_ex(entry->orig_value, 1);
zend_string_release_ex(entry->orig_value, true);
}
free(entry);
}
Expand All @@ -103,7 +103,7 @@ ZEND_API void zend_ini_startup(void) /* {{{ */
EG(ini_directives) = registered_zend_ini_directives;
EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL;
zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1);
zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, true);
}
/* }}} */

Expand Down Expand Up @@ -146,18 +146,18 @@ ZEND_API void zend_ini_deactivate(void) /* {{{ */
static void copy_ini_entry(zval *zv) /* {{{ */
{
zend_ini_entry *old_entry = (zend_ini_entry*)Z_PTR_P(zv);
zend_ini_entry *new_entry = pemalloc(sizeof(zend_ini_entry), 1);
zend_ini_entry *new_entry = pemalloc(sizeof(zend_ini_entry), true);

Z_PTR_P(zv) = new_entry;
memcpy(new_entry, old_entry, sizeof(zend_ini_entry));
if (old_entry->name) {
new_entry->name = zend_string_dup(old_entry->name, 1);
new_entry->name = zend_string_dup(old_entry->name, true);
}
if (old_entry->value) {
new_entry->value = zend_string_dup(old_entry->value, 1);
new_entry->value = zend_string_dup(old_entry->value, true);
}
if (old_entry->orig_value) {
new_entry->orig_value = zend_string_dup(old_entry->orig_value, 1);
new_entry->orig_value = zend_string_dup(old_entry->orig_value, true);
}
}
/* }}} */
Expand All @@ -167,7 +167,7 @@ ZEND_API void zend_copy_ini_directives(void) /* {{{ */
EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL;
EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1);
zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, true);
zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry);
}
/* }}} */
Expand All @@ -194,7 +194,7 @@ static int ini_key_compare(Bucket *f, Bucket *s) /* {{{ */

ZEND_API void zend_ini_sort_entries(void) /* {{{ */
{
zend_hash_sort(EG(ini_directives), ini_key_compare, 0);
zend_hash_sort(EG(ini_directives), ini_key_compare, false);
}
/* }}} */

Expand Down Expand Up @@ -224,9 +224,9 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
#endif

while (ini_entry->name) {
p = pemalloc(sizeof(zend_ini_entry), 1);
p = pemalloc(sizeof(zend_ini_entry), true);
p->def = ini_entry;
p->name = zend_string_init_interned(ini_entry->name, ini_entry->name_length, 1);
p->name = zend_string_init_interned(ini_entry->name, ini_entry->name_length, true);
p->on_modify = ini_entry->on_modify;
p->mh_arg1 = ini_entry->mh_arg1;
p->mh_arg2 = ini_entry->mh_arg2;
Expand All @@ -236,13 +236,13 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
p->displayer = ini_entry->displayer;
p->modifiable = ini_entry->modifiable;

p->orig_modifiable = 0;
p->modified = 0;
p->orig_modifiable = false;
p->modified = false;
p->module_number = module_number;

if (zend_hash_add_ptr(directives, p->name, (void*)p) == NULL) {
if (p->name) {
zend_string_release_ex(p->name, 1);
zend_string_release_ex(p->name, true);
}
pefree(p, true);
zend_unregister_ini_entries_ex(module_number, module_type);
Expand All @@ -260,7 +260,7 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
}
} else {
p->value = ini_entry->value ?
zend_string_init_interned(ini_entry->value, ini_entry->value_length, 1) : NULL;
zend_string_init_interned(ini_entry->value, ini_entry->value_length, true) : NULL;

if (p->on_modify) {
p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP);
Expand Down Expand Up @@ -348,7 +348,7 @@ ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *v
}
/* }}} */

ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */
ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, bool force_change) /* {{{ */
{
zend_result ret;
zend_string *new_value;
Expand Down Expand Up @@ -386,12 +386,12 @@ ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new

if (!EG(modified_ini_directives)) {
ALLOC_HASHTABLE(EG(modified_ini_directives));
zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, false);
}
if (!modified) {
ini_entry->orig_value = ini_entry->value;
ini_entry->orig_modifiable = modifiable;
ini_entry->modified = 1;
ini_entry->modified = true;
zend_hash_add_ptr(EG(modified_ini_directives), ini_entry->name, ini_entry);
}

Expand Down Expand Up @@ -428,7 +428,7 @@ ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage) /* {{{
}

if (EG(modified_ini_directives)) {
if (zend_restore_ini_entry_cb(ini_entry, stage) == 0) {
if (zend_restore_ini_entry_cb(ini_entry, stage) == SUCCESS) {
zend_hash_del(EG(modified_ini_directives), name);
} else {
return FAILURE;
Expand Down Expand Up @@ -457,7 +457,7 @@ ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name
* Data retrieval
*/

ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig) /* {{{ */
ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, bool orig) /* {{{ */
{
zend_ini_entry *ini_entry;

Expand All @@ -474,7 +474,7 @@ ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig)
}
/* }}} */

ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig) /* {{{ */
ZEND_API double zend_ini_double(const char *name, size_t name_length, bool orig) /* {{{ */
{
zend_ini_entry *ini_entry;

Expand All @@ -491,15 +491,15 @@ ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig)
}
/* }}} */

ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig, bool *exists) /* {{{ */
ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, bool orig, bool *exists) /* {{{ */
{
zend_string *str = zend_ini_str_ex(name, name_length, orig, exists);

return str ? ZSTR_VAL(str) : NULL;
}
/* }}} */

ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig) /* {{{ */
ZEND_API char *zend_ini_string(const char *name, size_t name_length, bool orig) /* {{{ */
{
zend_string *str = zend_ini_str(name, name_length, orig);

Expand Down Expand Up @@ -560,13 +560,13 @@ ZEND_API zend_string *zend_ini_get_value(zend_string *name) /* {{{ */
}
/* }}} */

ZEND_API bool zend_ini_parse_bool(zend_string *str)
ZEND_API bool zend_ini_parse_bool(const zend_string *str)
{
if (zend_string_equals_literal_ci(str, "true")
|| zend_string_equals_literal_ci(str, "yes")
|| zend_string_equals_literal_ci(str, "on")
) {
return 1;
return true;
} else {
return atoi(ZSTR_VAL(str)) != 0;
}
Expand Down Expand Up @@ -610,12 +610,12 @@ static const char *zend_ini_consume_quantity_prefix(const char *const digits, co
return digits_consumed;
}

static zend_ulong zend_ini_parse_quantity_internal(zend_string *value, zend_ini_parse_quantity_signed_result_t signed_result, zend_string **errstr) /* {{{ */
static zend_ulong zend_ini_parse_quantity_internal(const zend_string *value, zend_ini_parse_quantity_signed_result_t signed_result, zend_string **errstr) /* {{{ */
{
char *digits_end = NULL;
char *str = ZSTR_VAL(value);
char *str_end = &str[ZSTR_LEN(value)];
char *digits = str;
const char *str = ZSTR_VAL(value);
const char *str_end = &str[ZSTR_LEN(value)];
const char *digits = str;
bool overflow = false;
zend_ulong factor;
smart_str invalid = {0};
Expand Down Expand Up @@ -844,19 +844,19 @@ static zend_ulong zend_ini_parse_quantity_internal(zend_string *value, zend_ini_
}
/* }}} */

ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr) /* {{{ */
ZEND_API zend_long zend_ini_parse_quantity(const zend_string *value, zend_string **errstr) /* {{{ */
{
return (zend_long) zend_ini_parse_quantity_internal(value, ZEND_INI_PARSE_QUANTITY_SIGNED, errstr);
}
/* }}} */

ZEND_API zend_ulong zend_ini_parse_uquantity(zend_string *value, zend_string **errstr) /* {{{ */
ZEND_API zend_ulong zend_ini_parse_uquantity(const zend_string *value, zend_string **errstr) /* {{{ */
{
return zend_ini_parse_quantity_internal(value, ZEND_INI_PARSE_QUANTITY_UNSIGNED, errstr);
}
/* }}} */

ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string *setting) /* {{{ */
ZEND_API zend_long zend_ini_parse_quantity_warn(const zend_string *value, zend_string *setting) /* {{{ */
{
zend_string *errstr;
zend_long retval = zend_ini_parse_quantity(value, &errstr);
Expand All @@ -870,7 +870,7 @@ ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string
}
/* }}} */

ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_string *setting) /* {{{ */
ZEND_API zend_ulong zend_ini_parse_uquantity_warn(const zend_string *value, zend_string *setting) /* {{{ */
{
zend_string *errstr;
zend_ulong retval = zend_ini_parse_uquantity(value, &errstr);
Expand All @@ -886,21 +886,14 @@ ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_strin

ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
{
int value;
zend_string *tmp_value;
bool value;

if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
value = zend_ini_parse_bool(ini_entry->orig_value);
} else if (ini_entry->value) {
tmp_value = ini_entry->value;
} else {
tmp_value = NULL;
}

if (tmp_value) {
value = zend_ini_parse_bool(tmp_value);
value = zend_ini_parse_bool(ini_entry->value);
} else {
value = 0;
value = false;
}

if (value) {
Expand All @@ -913,7 +906,7 @@ ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */

ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
{
char *value;
const char *value;

if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ZSTR_VAL(ini_entry->orig_value);
Expand All @@ -940,7 +933,7 @@ ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */

ZEND_INI_DISP(display_link_numbers) /* {{{ */
{
char *value;
const char *value;

if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ZSTR_VAL(ini_entry->orig_value);
Expand Down
Loading