1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

527 Commits

Author SHA1 Message Date
Calvin Buckley
13b83a46cf Bump libtool to serial 63 from 2.5.4 (#21067)
The libtool 1.5.26 is bundled with PHP since the very early days of the
Autotools build system to ease the building process and avoid additional
dependency on the system Libtool. This updates the bundled libtool to
2.5.4 version.

Fixes and implementations:

- Fixed race conditions when building PHP in parallel ("cannot create
  .libs" warnings).
- Implements request https://bugs.php.net/70374 (Update libtool.m4)
- Fixes libtool eating -flto flags.
- Fixes GH-17310 (configure producing errors on macOS)
- Fixes GH-15946 (./configure error when building with NixOS)

Changes:
- Add a script to update autotools files.
- libtool is spread across multiple files; phpize is updated to handle
  this.
- Remove outdated hacks, i.e. for `ar`.
- Remove documentation references to external libtool, as we vendor it.
- `--with-pic` is now `--enable-pic`. Error out on the old flag.
- On macOS linker now uses -undefined dynamic_lookup flag for shared
  extensions and shared embed SAPI (libphp) instead of older
  '-undefined suppress -flat_namespace' combination.

Co-authored-by: Peter Kokot <peterkokot@gmail.com>
2026-03-11 12:37:56 -03:00
Peter Kokot
f17c5ad83b Windows build: Add new function CHECK_HEADER() (#21191)
The current function `CHECK_HEADER_ADD_INCLUDE()` automatically defines
`HAVE_<HEADER_NAME_H>` preprocessor macros, which makes it difficult to
sync with other build systems. Specially, if some `HAVE_` macro is used
in the code and this function defines this macro but Autotools doesn't.

The new `CHECK_HEADER()` function behaves similar except it doesn't
define the `HAVE_<HEADER_NAME_H>` preprocessor macro.

This removes the following unused compile definitions:

HAVE_ARGON2_H
HAVE_AVIF_H
HAVE_BZLIB_H
HAVE_CAPSTONE_CAPSTONE_H
HAVE_CURL_EASY_H
HAVE_DB_H
HAVE_DECODE_H
HAVE_DEPOT_H
HAVE_EDITLINE_READLINE_H
HAVE_ENCHANT_H
HAVE_ENCODE_H
HAVE_FFI_H
HAVE_FIREBIRD_INTERFACE_H
HAVE_FT2BUILD_H
HAVE_GD_H
HAVE_GLIB_H
HAVE_GMP_H
HAVE_HTTPD_H
HAVE_IBASE_H
HAVE_IR_IR_H
HAVE_KECCAKHASH_H
HAVE_LBER_H
HAVE_LDAP_H
HAVE_LIBEXSLT_EXSLT_H
HAVE_LIBINTL_H
HAVE_LIBPQ_FE_H
HAVE_LIBTIDY_TIDY_H
HAVE_LIBXML_PARSER_H
HAVE_LIBXML_TREE_H
HAVE_LIBXML_XMLWRITER_H
HAVE_LIBXSLT_XSLT_H
HAVE_LMDB_H
HAVE_MBSTRING_H
HAVE_MYSQL_H
HAVE_ONIGURUMA_H
HAVE_OPENSSL_SSL_H
HAVE_PNG_H
HAVE_SNMP_H
HAVE_SODIUM_H
HAVE_SQLITE3_H
HAVE_SQLITE3EXT_H
HAVE_SYBFRONT_H
HAVE_TIDY_H
HAVE_TIDY_TIDY_H
HAVE_TIDYBUFFIO_H
HAVE_TIMELIB_CONFIG_H
HAVE_UNICODE_USPOOF_H
HAVE_UNICODE_UTF_H
HAVE_XPM_H
HAVE_ZIP_H
HAVE_ZIPCONF_H
HAVE_ZLIB_H

The following compile definitions are defined explicitly:

- HAVE_ICONV_H
- HAVE_MSCOREE_H
- HAVE_SQL_H
- HAVE_SQLEXT_H

Additionally, the `SETUP_OPENSSL()` function doesn't accept the 6th
argument anymore.
2026-03-03 20:06:40 +01:00
Gina Peter Banyard
99bf26be0b ext/session: add mod_user_uses_object_methods_as_handlers global
This solves the use case of knowing if the session handlers are methods of an object or individual handlers without relying on the now removed mod_user_names global.
2026-02-16 14:27:45 +00:00
Tim Düsterhus
9c900b6e34 zend_compile: Bundle function type constants into an zend_function_type enum (#21208)
* zend_compile: Bundle function type constants into an `zend_function_type` enum

This clarifies the relationship between these constants and improves type
safety a little.

* Add C23_ENUM() helper macro

* zend_portability: Rename `size` to `underlying_type` in `C23_ENUM()`

* zend_portability: Include the leading `enum` in the `C23_ENUM` macro

* Fix comment for C23_ENUM()
2026-02-16 14:19:29 +01:00
Tim Düsterhus
7134e69ab2 zend_globals: Embed in_autoload into zend_executor_globals (#21202)
* zend_globals: Embed `in_autoload` into `zend_executor_globals`

Nowadays virtually any PHP application is making use of autoloading, making the
lazy allocation of the `HashTable` struct a needless pointer indirection.

* zend_globals: Rename `in_autoload` to `autoload_current_classnames`

The old name `in_autoload` was somewhat misleading by implying a `bool`ean
value rather than a `HashTable`. Since the previous change to embed the
`HashTable` is breaking anyway, we can also rename it.

* UPGRADING.INTERNALS
2026-02-11 22:53:31 +01:00
Peter Kokot
8032d6fa16 Autotools: Check struct stat.st_blocks with AC_CHECK_MEMBERS (#13562)
The AC_STRUCT_ST_BLOCKS expects fileblocks object to be compiled with
AC_LIBOBJ if stat.st_blocks is missing on the system. This can be
simplified with the usual AC_CHECK_MEMBERS since PHP is using the
stat.st_blocks (and stat.st_blksize) conditionally.

These members are mostly present on all POSIX-based systems except on
Windows these days.

This also removes the obsolete HAVE_ST_BLOCKS symbol:
https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/types.m4?h=v2.72#n1055

Additionally, the st_blksize and st_blocks members are checked
conditionally with HAVE_ preprocessor macros. Instead of filtering
Windows specifically here, the preprocessor macros
HAVE_STRUCT_STAT_ST_BLKSIZE and HAVE_STRUCT_STAT_ST_BLOCKS can be used.
2026-02-10 19:59:10 +01:00
Peter Kokot
ba996f7ae9 Add note about updated PHP version
[skip ci]
2026-02-10 16:21:31 +01:00
Gina Peter Banyard
4b01cd1bf3 ext/session/mod_mm: implement VALIDATE_SID handler (#21178)
Rather than "manually" doing it in the READ handler.

At the same time, get rid of various inconsistent legacy handler macro definitions, thus mandating all modules to implement the create and validate SID handlers.

The only handler that remains optional is the update timestamp one.
2026-02-10 12:17:47 +00:00
Tim Düsterhus
ad83353a3d Fix line wrapping in NEWS/UPGRADING/UPGRADING.INTERNALS 2026-02-09 22:45:09 +01:00
Tim Düsterhus
d1ffe6afd9 Fix extension order in UPGRADING.INTERNALS 2026-02-09 22:41:27 +01:00
Gina Peter Banyard
71096cd873 ext/session: use zend_strings for open handler 2026-02-09 10:49:59 +00:00
Gina Peter Banyard
f6088f574c ext/session: remove session_adapt_url() function
This is unused and only exist for the deprecated (and dangerous) GET/POST session ID feature
2026-02-09 10:49:59 +00:00
Gina Peter Banyard
a0de1ace41 ext/session: refactor session_write_close()
By making the underlying function return a bool and not do duplicate checks
2026-02-09 10:49:59 +00:00
Nurzhan Bazhirov
b843e03c83 Zend: Remove unused parameter from zend_dval_to_lval_cap()
The `zend_string *s` parameter became unused after commit f754ffa8b2
(GH-20746) removed the `zend_oob_string_to_long_error()` calls.

This fixes an unused-parameter compiler warning and updates a stale
comment in zend_operators.c that incorrectly stated this function
can emit warnings.

Closes GH-21112
2026-02-04 15:25:42 +01:00
Tim Düsterhus
a15ba7672c zend_ini: Make ZEND_INI_GET_ADDR() return a void* pointer (#21119)
* zend_ini: Make `ZEND_INI_GET_ADDR()` return a `void*` pointer

Since the actual type of the storage location is not known, a `void*` is more
appropriate and avoids explicit casts that are no more safe than the implicit
cast from `void*`.

* tree-wide: Remove explicit casts of `ZEND_INI_GET_ADDR()`

* UPGRADING.INTERNALS
2026-02-04 11:11:11 +01:00
Arnaud Le Blanc
d16e6f52a4 Generate C enums from internal enums, introduce Z_PARAM_ENUM() (#20917)
Update gen_stubs.php to generate C enums from internal enums, when the stub is annotated with @generate-c-enums. Enum values can be compared to the result of zend_enum_fetch_case_id(zend_object*).

The generated enums are added to separate files named {$extensionName}_decl.h, so that it's possible to include these from anywhere. _arginfo.h files would generate warnings if we tried to include them in a compilation unit that doesn't call the register_{$class} functions, for instance.

Introduce Z_PARAM_ENUM().

* Make ZEND_AST_CONST_ENUM_INIT a 4-children node

* Store enum case id in ZEND_AST_CONST_ENUM_INIT

* Store enum case id in instance

* Expose enum case_id internally

* Generate C enum for internal enums

* Introduce Z_PARAM_ENUM()

* Port extensions
2026-02-03 12:38:04 +01:00
Ilija Tovilo
6173a9a109 VAR|TMP overhaul (GH-20628)
The aim of this PR is twofold:

- Reduce the number of highly similar TMP|VAR handlers
- Avoid ZVAL_DEREF in most of these cases

This is achieved by guaranteeing that all zend_compile_expr() calls, as well as
all other compile calls with BP_VAR_{R,IS}, will result in a TMP variable. This
implies that the result will not contain an IS_INDIRECT or IS_REFERENCE value,
which was mostly already the case, with two exceptions:

- Calls to return-by-reference functions. Because return-by-reference functions
  are quite rare, this is solved by delegating the DEREF to the RETURN_BY_REF
  handler, which will examine the stack to check whether the caller expects a
  VAR or TMP to understand whether the DEREF is needed. Internal functions will
  also need to adjust by calling the zend_return_unwrap_ref() function.

- By-reference assignments, including both $a = &$b, as well as $a = [&$b]. When
  the result of these expressions is used in a BP_VAR_R context, the reference
  is unwrapped via a ZEND_QM_ASSIGN opcode beforehand. This is exceptionally
  rare.

Closes GH-20628
2026-01-31 19:44:56 +01:00
Tim Düsterhus
c8c9ff6d04 Add ZEND_TYPE_ASSERT to UPGRADING.INTERNALS (#21014)
Following php/php-src#20934 which introduced the OPcode.
2026-01-23 13:17:49 +01:00
Kamil Tekiela
3ed4d2a82b Drop extraneous parameter (#20977) 2026-01-20 13:06:52 +00:00
Ilija Tovilo
084e409694 Remove zend_exception_save() and zend_exception_restore()
These are leftovers from the pre-PHP-7.0 era. This also implicitly solves
GH-20564 by not clearing exceptions before entering the autoloader.

Closes GH-20256
Fixes GH-20564
2026-01-16 20:18:51 +01:00
Arnaud Le Blanc
ef522525cf Introduce zend_ast_call_get_args() (#20859) 2026-01-08 11:46:10 +01:00
Gina Peter Banyard
c727f4d6c5 ext/standard/mail: use zend_string* for extra_cmd param of php_mail() 2025-12-27 23:26:58 +00:00
Gina Peter Banyard
b86f107076 ext/standard: refactor _php_error_log()
In preparation for php_mail() refactoring
2025-12-27 23:26:58 +00:00
Arnaud Le Blanc
626f3c3c7c Unify arg info representation for internal and user functions
The arg_info member of zend_function is now always a zend_arg_info*. Before,
it was a zend_internal_arg_info* on internal functions, unless the
ZEND_ACC_USER_ARG_INFO flag was set.

Closes GH-19022
2025-12-15 16:50:49 +01:00
Heran Yang
1f3fe93eff Add GB18030-2022 to default encoding list for zh-CN (#20604)
GB18030-2022 is the current official standard, superseding the previous 2005 and 2000 versions. It is essential for modern Chinese text processing for the following reasons:

    1. Superset Relationship: GB18030 is a strict superset of CP936 (GBK) and EUC-CN (GB2312). Using GB18030 as the detection target covers all characters in these older encodings while enabling support for a much wider range of characters.
    2. Extended Character Coverage: The 2022 standard includes significant updates, covering over 87,000 characters. It adds support for CJK Extensions (C, D, E, F, G) and updates mappings for rare characters that were previously mapped to the Private Use Area (PUA) in the 2005 version. This is critical for correctly handling names containing rare characters (e.g., in banking or government data).
    3. Backward Compatibility: It is safe to promote GB18030-2022 as the preferred encoding. Files encoded in EUC-CN or CP936 are valid GB18030 streams.

This PR adds GB18030-2022 to the default encoding list for CN.
2025-12-12 11:58:37 +09:00
Peter Kokot
88d811708b Remove PHP_HAVE_STREAMS (#20508)
This was once an indicator for PHP extensions whether PHP 4.3.0 or later
is used. Today, this is redundant.
2025-11-17 13:05:22 +01:00
Niels Dossche
11070509ae xml: Drop unused XML_GetCurrentByteCount() compatibility wrapper (#20476) 2025-11-14 18:23:13 +01:00
Niels Dossche
9cd367362d [ci skip] UPGRADING.INTERNALS entry for 94831808 2025-11-13 23:33:50 +01:00
Tim Düsterhus
db8d35e7eb tree-wide: Replace ZEND_WRONG_PARAM_COUNT() by its definition (#20066)
* tree-wide: Replace `WRONG_PARAM_COUNT` by `ZEND_WRONG_PARAM_COUNT()`

This is a direct alias.

* tree-wide: Replace `ZEND_WRONG_PARAM_COUNT()` by its definition

This macro was hiding control flow (the return statement) and thus was
particularly unhygienic.
2025-11-12 21:28:56 +01:00
Niels Dossche
b69025807b standard: Avoid double hash table lookup in iptcparse()
Closes GH-20420.
2025-11-08 13:33:12 +01:00
Gina Peter Banyard
55d449fca4 Zend: remove zend_set_hash_symbol() API (#20413)
This is unused both within php-src and a SourceGraph search returned 0 results.

This is also confusing as it talks about symbol tables without actually using any of the corresponding update functions.
2025-11-07 20:01:04 +00:00
Gina Peter Banyard
423e50c57d zend_object_handler.c: call zend_get_call_trampoline_func() and pass zend_function* directly (#20297)
Abstracting away the bool parameter is not that useful, and doesn't make the code more legible.
Moreover, it is not needed if one passes the zend_function* directly, which we always have.
This is because it can be derived/copied from the fn_flags.
2025-11-05 21:46:32 +00:00
Gina Peter Banyard
23162d852a Add UPGRADING information for Zend API change
Related to 7815ab9b22
2025-10-29 13:24:36 +00:00
Gina Peter Banyard
c0214e49d2 Zend: remove zend_make_callable() function (#20269)
The name of this function is confusing, it doesn't make a zval callable just normalizes strings to an array pair if the string references a static method.
In general, to store a userland function it is encouraged to store the resolved FCC rather than the zval.

Moreover, a sourcegraph search shows no usage of this API in external open source code.
2025-10-26 18:28:40 +00:00
Gina Peter Banyard
275ec6f335 Zend: make zend_copy_parameters_array() private (#20265)
And slightly refactor implementation.
2025-10-25 22:36:09 +01:00
Niels Dossche
df8ce6ddbd Zend: remove zval_dtor() compatibility macro
This is an alias for zval_ptr_dtor_nogc().
I've seen people make mistakes against this and use zval_dtor() instead
of zval_ptr_dtor(). The crucial detail here is that the former won't
root possible GC cycles while the latter will.
We can avoid the confusion by just retiring this compatibility macro.

Closes GH-20235.
2025-10-20 20:38:21 +02:00
Tim Düsterhus
1ef7abf2be zend_long: Remove ZEND_LTOA() (#20236)
* zend_long: Remove `ZEND_LTOA()`

This macro is unsafe when the given buffer is too small, since `snprintf()`
returns the *required* length of the string if it would fit. Thus
unconditionally writing a NUL there might result in a out-of-bounds write.

* zend_long: Remove `ZEND_LTOA_BUF_LEN`
2025-10-20 08:36:41 +02:00
Tim Düsterhus
6da93a86f2 zend_API: Remove CHECK*NULL_PATH (#20155)
* tree-wide: Replace `CHECK_NULL_PATH()` by `zend_char_has_nul_byte()`

The former is a direct alias of the latter with a more explicit name and the
former is explicitly documented as a “compatibility” alias.

* tree-wide: Replace `CHECK_ZVAL_NULL_PATH()` by its definition

The former is explicitly documented as a “compatibility” alias.

* zend_API: Remove `CHECK*NULL_PATH`

The `CHECK_ZVAL_NULL_PATH()` macro is unsafe, because it implicitly assumes
that the given `zval*` is `IS_STRING`.

Based on a GitHub search there does not seem to be any user outside of PHP, all
hits were just forks / copies of php-src.
2025-10-15 10:24:22 +02:00
Tim Düsterhus
e1240f25df zend_operators: Remove _zval_get_*() PHP 7.2 compatibility macros (#20152)
These have been unused for long enough and just pollute the symbol namespace.
2025-10-14 10:20:16 +02:00
Tim Düsterhus
985d681501 tree-wide: Replace zval_is_true() by zend_is_true() (#20065)
* tree-wide: Replace `zval_is_true()` by `zend_is_true()`

The former is a direct alias of the latter which is much more often used.

* zend_operators: Remove `zval_is_true()`
2025-10-07 20:44:32 +02:00
Ilija Tovilo
a3f0861f2e [skip ci] Mention new ce_flags2 and fn_flags2 fields in UPGRADING.INTERNALS 2025-09-30 22:58:30 +02:00
Tim Düsterhus
f566312b54 zend_API: Remove ZVAL_IS_NULL() (#19986)
The `ZVAL_*()` macros are setters, the `Z_*()` macros are getters.
2025-09-29 12:35:22 +02:00
Tim Düsterhus
5d431d0d74 zend_string: Support NUL bytes in ZSTR_*_LITERAL() and zend_string_*literal*() (#19582) 2025-09-25 12:11:22 +02:00
Daniel Scherzer
a4c712c379 master is now for PHP 8.6.0-dev 2025-09-23 14:59:55 -04:00
Tim Düsterhus
0b74e59d79 Fix organization of UPGRADING.INTERNALS (#19635) 2025-09-01 16:03:51 +02:00
Tim Düsterhus
fc467dcb64 random: Use ->default_object_handlers for engines (#19625) 2025-08-29 11:12:46 +02:00
Daniel Scherzer
63acc4bf61 [RFC] Add #[\DelayedTargetValidation] attribute (#18817)
https://wiki.php.net/rfc/delayedtargetvalidation_attribute
2025-08-20 00:41:20 -07:00
Máté Kocsis
1cff1815d0 Add internal URI handling API (#19073)
Part of https://github.com/php/php-src/pull/14461. Related to https://wiki.php.net/rfc/url_parsing_api.
2025-08-19 18:35:09 +02:00
Alexandre Daubois
bf64dfcd99 Add an enum for HASH_KEY_IS_* constants (GH-19376) 2025-08-13 13:59:01 +02:00
Alexandre Daubois
74c006fbab Use proper hash_spec_result enum for return values in ext/hash (#19386) 2025-08-09 12:56:40 +02:00