Skip to content
Open
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
8 changes: 8 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ PHP 8.6 INTERNALS UPGRADE NOTES
longer is a pointer, but a directly embedded HashTable struct.
. Added a C23_ENUM() helper macro to define forward-compatible fixed-size
enums.
. The INI_STR(), INI_INT(), INI_FLT(), and INI_BOOL() macros have been
removed. Instead new zend_ini_{bool|long|double|str|string}_literal()
macros have been added. This fixes an internal naming inconsistency as
"str" usually means zend_string*, and "string" means char*.
However INI_STR() returned a char*
. The INI_ORIG_{INT|STR|FLT|BOOL}() macros have been removed as they are
unused. If this behaviour is required fall back to the zend_ini_*
functions.

========================
2. Build system changes
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_fibers.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,9 @@ static ZEND_STACK_ALIGNED void zend_fiber_execute(zend_fiber_transfer *transfer)
zend_fiber *fiber = EG(active_fiber);

/* Determine the current error_reporting ini setting. */
zend_long error_reporting = INI_INT("error_reporting");
/* If error_reporting is 0 and not explicitly set to 0, INI_STR returns a null pointer. */
if (!error_reporting && !INI_STR("error_reporting")) {
zend_long error_reporting = zend_ini_long_literal("error_reporting");
/* If error_reporting is 0 and not explicitly set to 0, zend_ini_str returns a null pointer. */
if (!error_reporting && !zend_ini_str_literal("error_reporting")) {
error_reporting = E_ALL;
}

Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_highlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
{
zval token;
int token_type;
char *last_color = syntax_highlighter_ini->highlight_html;
char *next_color;
const char *last_color = syntax_highlighter_ini->highlight_html;
const char *next_color;

zend_printf("<pre><code style=\"color: %s\">", last_color);
/* highlight stuff coming back from zendlex() */
Expand Down
10 changes: 5 additions & 5 deletions Zend/zend_highlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@


typedef struct _zend_syntax_highlighter_ini {
char *highlight_html;
char *highlight_comment;
char *highlight_default;
char *highlight_string;
char *highlight_keyword;
const char *highlight_html;
const char *highlight_comment;
const char *highlight_default;
const char *highlight_string;
const char *highlight_keyword;
} zend_syntax_highlighter_ini;


Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,15 @@ ZEND_API double zend_ini_double(const char *name, size_t name_length, bool orig)
}
/* }}} */

ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, bool orig, bool *exists) /* {{{ */
ZEND_API const 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, bool orig) /* {{{ */
ZEND_API const 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
20 changes: 8 additions & 12 deletions Zend/zend_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,19 @@ ZEND_API void display_ini_entries(zend_module_entry *module);

ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, bool orig);
ZEND_API double zend_ini_double(const char *name, size_t name_length, bool orig);
ZEND_API char *zend_ini_string(const char *name, size_t name_length, bool orig);
ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, bool orig, bool *exists);
ZEND_API const char *zend_ini_string(const char *name, size_t name_length, bool orig);
ZEND_API const char *zend_ini_string_ex(const char *name, size_t name_length, bool orig, bool *exists);
ZEND_API zend_string *zend_ini_str(const char *name, size_t name_length, bool orig);
ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool orig, bool *exists);
ZEND_API zend_string *zend_ini_get_value(zend_string *name);
ZEND_API bool zend_ini_parse_bool(const zend_string *str);

#define zend_ini_bool_literal(name) zend_ini_parse_bool(zend_ini_str((name), sizeof("" name) - 1, false))
#define zend_ini_long_literal(name) zend_ini_long((name), sizeof("" name) - 1, false)
#define zend_ini_double_literal(name) zend_ini_double((name), sizeof("" name) - 1, false)
#define zend_ini_str_literal(name) zend_ini_str((name), sizeof("" name) - 1, false)
#define zend_ini_string_literal(name) zend_ini_string((name), sizeof("" name) - 1, false)

/**
* Parses an ini quantity
*
Expand Down Expand Up @@ -191,16 +197,6 @@ END_EXTERN_C()
ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, zend_ini_boolean_displayer_cb)
#endif

#define INI_INT(name) zend_ini_long((name), strlen(name), 0)
#define INI_FLT(name) zend_ini_double((name), strlen(name), 0)
#define INI_STR(name) zend_ini_string_ex((name), strlen(name), 0, NULL)
#define INI_BOOL(name) ((bool) INI_INT(name))

#define INI_ORIG_INT(name) zend_ini_long((name), strlen(name), 1)
#define INI_ORIG_FLT(name) zend_ini_double((name), strlen(name), 1)
#define INI_ORIG_STR(name) zend_ini_string((name), strlen(name), 1)
#define INI_ORIG_BOOL(name) ((bool) INI_ORIG_INT(name))

#define REGISTER_INI_ENTRIES() zend_register_ini_entries_ex(ini_entries, module_number, type)
#define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries_ex(module_number, type)
#define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_multibyte.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ ZEND_API zend_result zend_multibyte_set_functions(const zend_multibyte_functions
* populated, we need to reinitialize script_encoding here.
*/
{
const char *value = zend_ini_string("zend.script_encoding", sizeof("zend.script_encoding") - 1, 0);
zend_multibyte_set_script_encoding_by_string(value, strlen(value));
const zend_string *value = zend_ini_str_literal("zend.script_encoding");
zend_multibyte_set_script_encoding_by_string(ZSTR_VAL(value), ZSTR_LEN(value));
}
return SUCCESS;
}
Expand Down
7 changes: 3 additions & 4 deletions ext/com_dotnet/com_dotnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ static HRESULT dotnet_bind_runtime(LPVOID FAR *ppv)
typedef HRESULT (STDAPICALLTYPE *cbtr_t)(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv);
cbtr_t CorBindToRuntime;
OLECHAR *oleversion;
char *version;

mscoree = LoadLibraryA("mscoree.dll");
if (mscoree == NULL) {
Expand All @@ -140,11 +139,11 @@ static HRESULT dotnet_bind_runtime(LPVOID FAR *ppv)
return S_FALSE;
}

version = INI_STR("com.dotnet_version");
if (version == NULL || *version == '\0') {
const zend_string *version = zend_ini_str_literal("com.dotnet_version");
if (version == NULL || ZSTR_LEN(version) == 0) {
oleversion = NULL;
} else {
oleversion = php_com_string_to_olestring(version, strlen(version), COMG(code_page));
oleversion = php_com_string_to_olestring(ZSTR_VAL(version), ZSTR_LEN(version), COMG(code_page));
}

hr = CorBindToRuntime(oleversion, NULL, &CLSID_CorRuntimeHost, &IID_ICorRuntimeHost, ppv);
Expand Down
6 changes: 2 additions & 4 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,6 @@ static void create_certinfo(struct curl_certinfo *ci, zval *listcode)
Set default options for a handle */
static void _php_curl_set_default_options(php_curl *ch)
{
char *cainfo;

curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
Expand All @@ -1114,9 +1112,9 @@ static void _php_curl_set_default_options(php_curl *ch)
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120L);
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20L); /* prevent infinite redirects */

cainfo = INI_STR("openssl.cafile");
const char* cainfo = zend_ini_string_literal("openssl.cafile");
if (!(cainfo && cainfo[0] != '\0')) {
cainfo = INI_STR("curl.cainfo");
cainfo = zend_ini_string_literal("curl.cainfo");
}
if (cainfo && cainfo[0] != '\0') {
curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo);
Expand Down
8 changes: 4 additions & 4 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -5480,18 +5480,18 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s
ZEND_PARSE_PARAMETERS_END();

if (latitude_is_null) {
latitude = INI_FLT("date.default_latitude");
latitude = zend_ini_double_literal("date.default_latitude");
}

if (longitude_is_null) {
longitude = INI_FLT("date.default_longitude");
longitude = zend_ini_double_literal("date.default_longitude");
}

if (zenith_is_null) {
if (calc_sunset) {
zenith = INI_FLT("date.sunset_zenith");
zenith = zend_ini_double_literal("date.sunset_zenith");
} else {
zenith = INI_FLT("date.sunrise_zenith");
zenith = zend_ini_double_literal("date.sunrise_zenith");
}
}

Expand Down
2 changes: 1 addition & 1 deletion ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,

#ifdef HAVE_GD_JPG
case PHP_GDIMG_TYPE_JPG:
ignore_warning = INI_INT("gd.jpeg_ignore_warning");
ignore_warning = zend_ini_bool_literal("gd.jpeg_ignore_warning");
im = gdImageCreateFromJpegEx(fp, ignore_warning);
break;
#endif
Expand Down
56 changes: 25 additions & 31 deletions ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,17 +1216,17 @@ PHP_FUNCTION(mb_language)
ZEND_PARSE_PARAMETERS_END();

if (name == NULL) {
RETVAL_STRING((char *)mbfl_no_language2name(MBSTRG(language)));
RETVAL_STRING(mbfl_no_language2name(MBSTRG(language)));
} else {
zend_string *ini_name = ZSTR_INIT_LITERAL("mbstring.language", 0);
zend_string *ini_name = ZSTR_INIT_LITERAL("mbstring.language", false);
if (FAILURE == zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)) {
zend_argument_value_error(1, "must be a valid language, \"%s\" given", ZSTR_VAL(name));
zend_string_release_ex(ini_name, 0);
zend_string_release_ex(ini_name, false);
RETURN_THROWS();
}
// TODO Make return void
RETVAL_TRUE;
zend_string_release_ex(ini_name, 0);
zend_string_release_ex(ini_name, false);
}
}
/* }}} */
Expand Down Expand Up @@ -1509,7 +1509,7 @@ PHP_FUNCTION(mb_preferred_mime_name)
php_error_docref(NULL, E_WARNING, "No MIME preferred name corresponding to \"%s\"", name);
RETVAL_FALSE;
} else {
RETVAL_STRING((char *)preferred_name);
RETVAL_STRING(preferred_name);
}
}
/* }}} */
Expand Down Expand Up @@ -3517,7 +3517,7 @@ PHP_FUNCTION(mb_detect_encoding)
RETURN_FALSE;
}

RETVAL_STRING((char *)ret->name);
RETVAL_STRING(ret->name);
}
/* }}} */

Expand Down Expand Up @@ -3563,7 +3563,7 @@ PHP_FUNCTION(mb_encoding_aliases)
array_init(return_value);
if (encoding->aliases != NULL) {
for (const char **alias = encoding->aliases; *alias; ++alias) {
add_next_index_string(return_value, (char *)*alias);
add_next_index_string(return_value, *alias);
}
}
}
Expand Down Expand Up @@ -4768,7 +4768,7 @@ PHP_FUNCTION(mb_send_mail)

str_headers = smart_str_extract(&str);

zend_string *force_extra_parameters = zend_ini_str_ex("mail.force_extra_parameters", strlen("mail.force_extra_parameters"), false, NULL);
zend_string *force_extra_parameters = zend_ini_str_literal("mail.force_extra_parameters");
if (force_extra_parameters) {
extra_cmd = php_escape_shell_cmd(force_extra_parameters);
} else if (extra_cmd) {
Expand Down Expand Up @@ -4804,7 +4804,7 @@ PHP_FUNCTION(mb_get_info)
{
zend_string *type = NULL;
size_t n;
char *name;
const char *name;
zval row;
const mbfl_encoding **entry;
const mbfl_language *lang = mbfl_no2language(MBSTRG(language));
Expand All @@ -4819,26 +4819,26 @@ PHP_FUNCTION(mb_get_info)
if (!type || zend_string_equals_literal_ci(type, "all")) {
array_init(return_value);
if (MBSTRG(current_internal_encoding)) {
add_assoc_string(return_value, "internal_encoding", (char *)MBSTRG(current_internal_encoding)->name);
add_assoc_string(return_value, "internal_encoding", MBSTRG(current_internal_encoding)->name);
}
if (MBSTRG(http_input_identify)) {
add_assoc_string(return_value, "http_input", (char *)MBSTRG(http_input_identify)->name);
add_assoc_string(return_value, "http_input", MBSTRG(http_input_identify)->name);
}
if (MBSTRG(current_http_output_encoding)) {
add_assoc_string(return_value, "http_output", (char *)MBSTRG(current_http_output_encoding)->name);
add_assoc_string(return_value, "http_output", MBSTRG(current_http_output_encoding)->name);
}

add_assoc_str(return_value, "http_output_conv_mimetypes",
zend_ini_str("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes") - 1, 0)
zend_string_copy(zend_ini_str_literal("mbstring.http_output_conv_mimetypes"))
);

name = (char *)mbfl_no_encoding2name(lang->mail_charset);
name = mbfl_no_encoding2name(lang->mail_charset);
add_assoc_string(return_value, "mail_charset", name);

name = (char *)mbfl_no_encoding2name(lang->mail_header_encoding);
name = mbfl_no_encoding2name(lang->mail_header_encoding);
add_assoc_string(return_value, "mail_header_encoding", name);

name = (char *)mbfl_no_encoding2name(lang->mail_body_encoding);
name = mbfl_no_encoding2name(lang->mail_body_encoding);
add_assoc_string(return_value, "mail_body_encoding", name);

add_assoc_long(return_value, "illegal_chars", MBSTRG(illegalchars));
Expand All @@ -4849,7 +4849,7 @@ PHP_FUNCTION(mb_get_info)
add_assoc_string(return_value, "encoding_translation", "Off");
}

name = (char *)mbfl_no_language2name(MBSTRG(language));
name = mbfl_no_language2name(MBSTRG(language));
add_assoc_string(return_value, "language", name);

// TODO Seems to always have one entry at least?
Expand Down Expand Up @@ -4880,31 +4880,25 @@ PHP_FUNCTION(mb_get_info)
}
} else if (zend_string_equals_literal_ci(type, "internal_encoding")) {
ZEND_ASSERT(MBSTRG(current_internal_encoding));
RETURN_STRING((char *)MBSTRG(current_internal_encoding)->name);
RETURN_STRING(MBSTRG(current_internal_encoding)->name);
} else if (zend_string_equals_literal_ci(type, "http_input")) {
if (MBSTRG(http_input_identify)) {
RETURN_STRING((char *)MBSTRG(http_input_identify)->name);
RETURN_STRING(MBSTRG(http_input_identify)->name);
}
RETURN_NULL();
} else if (zend_string_equals_literal_ci(type, "http_output")) {
ZEND_ASSERT(MBSTRG(current_http_output_encoding));
RETURN_STRING((char *)MBSTRG(current_http_output_encoding)->name);
RETURN_STRING(MBSTRG(current_http_output_encoding)->name);
} else if (zend_string_equals_literal_ci(type, "http_output_conv_mimetypes")) {
RETURN_STR(
zend_ini_str(
"mbstring.http_output_conv_mimetypes",
sizeof("mbstring.http_output_conv_mimetypes") - 1,
false
)
);
RETURN_STR_COPY(zend_ini_str_literal("mbstring.http_output_conv_mimetypes"));
} else if (zend_string_equals_literal_ci(type, "mail_charset")) {
name = (char *)mbfl_no_encoding2name(lang->mail_charset);
name = mbfl_no_encoding2name(lang->mail_charset);
RETURN_STRING(name);
} else if (zend_string_equals_literal_ci(type, "mail_header_encoding")) {
name = (char *)mbfl_no_encoding2name(lang->mail_header_encoding);
name = mbfl_no_encoding2name(lang->mail_header_encoding);
RETURN_STRING(name);
} else if (zend_string_equals_literal_ci(type, "mail_body_encoding")) {
name = (char *)mbfl_no_encoding2name(lang->mail_body_encoding);
name = mbfl_no_encoding2name(lang->mail_body_encoding);
RETURN_STRING(name);
} else if (zend_string_equals_literal_ci(type, "illegal_chars")) {
RETURN_LONG(MBSTRG(illegalchars));
Expand All @@ -4915,7 +4909,7 @@ PHP_FUNCTION(mb_get_info)
RETURN_STRING("Off");
}
} else if (zend_string_equals_literal_ci(type, "language")) {
name = (char *)mbfl_no_language2name(MBSTRG(language));
name = mbfl_no_language2name(MBSTRG(language));
RETURN_STRING(name);
} else if (zend_string_equals_literal_ci(type, "detect_order")) {
// TODO Seems to always have one entry at least?
Expand Down
6 changes: 2 additions & 4 deletions ext/openssl/openssl_backend_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,8 @@ void php_openssl_set_cert_locations(zval *return_value)
add_assoc_string(return_value, "default_cert_dir_env", (char *) X509_get_default_cert_dir_env());
add_assoc_string(return_value, "default_private_dir", (char *) X509_get_default_private_dir());
add_assoc_string(return_value, "default_default_cert_area", (char *) X509_get_default_cert_area());
add_assoc_string(return_value, "ini_cafile",
zend_ini_string("openssl.cafile", sizeof("openssl.cafile")-1, 0));
add_assoc_string(return_value, "ini_capath",
zend_ini_string("openssl.capath", sizeof("openssl.capath")-1, 0));
add_assoc_str(return_value, "ini_cafile", zend_string_copy(zend_ini_str_literal("openssl.cafile")));
add_assoc_str(return_value, "ini_capath", zend_string_copy(zend_ini_str_literal("openssl.capath")));
}

X509 *php_openssl_x509_from_str(
Expand Down
Loading
Loading