1398 Commits
Author SHA1 Message Date
ndossche 746a684eae Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix GH-24438: Preserve indirect types in JIT side traces
  Fix GH-17733: System entropy does not take into account function order, resulting in wrong functions possibly called in different configurations
  ext/openssl: Fix build with OpenSSL 4.1 (#24686)
2026-10-26 18:44:06 +01:00
ndossche ca0030ba18 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-24438: Preserve indirect types in JIT side traces
  Fix GH-17733: System entropy does not take into account function order, resulting in wrong functions possibly called in different configurations
2026-10-26 18:44:01 +01:00
ndossche 018b0a8d4d Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-24438: Preserve indirect types in JIT side traces
  Fix GH-17733: System entropy does not take into account function order, resulting in wrong functions possibly called in different configurations
2026-10-26 18:43:42 +01:00
ndossche d6541df639 Fix GH-17733: System entropy does not take into account function order, resulting in wrong functions possibly called in different configurations
This properly fixes the entropy computation to take into account
function ordering and module versions. This is basically a
reintroduction of the previously removed code from GH-5871, but a
simpler version. Since this runs once every module startup, the overhead
is negligible as it does not influence the request.

I chose this simple approach rather than the suggestion to introduce
multiple system entropies based on shm/file-cache.

This PR also simplifies some other parts, since we can get rid of some
workarounds.

Closes GH-24664.
2026-10-26 18:42:09 +01:00
Lazizbek Ergashev 551967dd91 Fix GH-24491: Static method stream error handler replaces pending exception (#24520)
Since 2f7b01b86c, `zend_is_callable()` fills in an error string even when it fails because an exception is already pending, so `php_stream_call_error_handler()` threw a TypeError over the StreamException (or whatever the user error handler threw) for any `Class::method` handler. It now only throws when nothing is pending, the same way curl already does.

The same commit made `zend_parse_arg()` leak that error string when it bails out on a pending exception, so it's freed there now too.

Fixes GH-24491
2026-10-23 20:57:32 +01:00
Ilija Tovilo 9705fda1bb Merge branch 'PHP-8.6' into master
* PHP-8.6:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:34:56 +02:00
Ilija Tovilo d6373dfe15 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:33:23 +02:00
Ilija Tovilo c7273b9ba8 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:30:04 +02:00
Ilija Tovilo 8a94bb3822 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:27:03 +02:00
Ilija Tovilo c1a5f468d0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:12:35 +02:00
3584a98bda Avoid state corruption via bailout
- Replace bailout on OOM with UnwindExit
- Properly reset various globals that may be accessed during startup

Fix GHSA-w8hw-w9fx-j79w (CVE-2026-109618)
Fix GHSA-6wmf-4rv5-p3rp (CVE-2026-109619)

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Jakub Zelenka <bukka@php.net>
Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
2026-10-21 16:06:22 +02:00
Gina Peter BanyardandArnaud Le Blanc 2f7b01b86c Zend: always populate error pointer on failure of zend_is_callable() (#24435)
* Zend: always populate error pointer on failure

Most of the code base expects an error to be set if a char* is provided, as this used to be always the case. It no longer was the case since the partially supported callables were deprecates as the deprecation could be promoted to an exception in which case we skipped allocating a char*.

The simple fix, allocate a char* even in case of an exception so callers don't need to check if it still NULL. This fixes some error messages at the same time.

* tree: simplify error handling for failed zend_is_callable() calls

* docs: clarify docs for zend_is_callable()

---------

Co-authored-by: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com>
2026-10-20 17:59:02 +01:00
Gina Peter Banyard de6f052c36 Zend: add zend_cannot_instantiate_class() (#24336) 2026-10-15 23:06:22 +01:00
Gina Peter Banyard 473ad224a1 Zend: use ce parameter name consistently for zend_class_entry* (#24150) 2026-10-06 12:27:28 +01:00
Ilia Alshanetsky cd8312e052 Merge branch 'PHP-8.6'
* PHP-8.6:
  Zend: Include frameless functions in the system id
2026-10-02 16:17:22 -04:00
Ilia Alshanetsky 4e5516af1d Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Zend: Include frameless functions in the system id
2026-10-02 16:17:21 -04:00
Ilia Alshanetsky 9eedb12de5 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Zend: Include frameless functions in the system id
2026-10-02 16:17:18 -04:00
Ilia Alshanetsky 1bffb94a2f Zend: Include frameless functions in the system id
FRAMELESS_ICALL stores an index into zend_flf_handlers, whose layout
depends on the loaded extensions, but zend_system_id did not cover it. A
file cache warmed with a frameless-declaring extension then crashed in a
process without it, or one that loads it with dl(), which registers no
frameless handlers. Each persistent frameless function now adds its name
and arity to the system id when it registers, before disable_functions can
free the function record.

Closes GH-24047
2026-10-02 16:17:03 -04:00
David Carlier b205b6f879 Merge branch 'PHP-8.6'
* PHP-8.6:
  ext/soap: to_xml_array() heap use-after-free with illegal iterator keys.
2026-10-01 19:13:19 +01:00
David Carlier 58f680c81e Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  ext/soap: to_xml_array() heap use-after-free with illegal iterator keys.
2026-10-01 19:13:18 +01:00
David Carlier 81a83bb33a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/soap: to_xml_array() heap use-after-free with illegal iterator keys.

# Conflicts:
#	Zend/zend_API.c
2026-10-01 19:12:52 +01:00
David Carlier d044f28b80 ext/soap: to_xml_array() heap use-after-free with illegal iterator keys.
Fix #22895

The return value of array_set_zval_key() was ignored, so when the key is
not a legal array offset, e.g. MultipleIterator::key() returning an
array, it threw and took no reference. The unconditional zval_ptr_dtor()
then dropped the iterator's only reference to the borrowed value and the
following Z_TRY_ADDREF_P() read freed memory. array_set_zval_key() now
also fails when a float or resource key diagnostic throws, and the loop
stops on failure.

Close GH-22896
2026-10-01 19:12:01 +01:00
Gina Peter Banyard 4d35f4a9c8 Zend: use new zend_object_copy() API 2026-10-01 12:43:56 +01:00
Ilia Alshanetsky 777de89757 Merge branch 'PHP-8.6'
* PHP-8.6:
  Zend: Skip frameless registration for temporary modules
2026-09-30 11:00:02 -04:00
Ilia Alshanetsky 1a95cbee88 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Zend: Skip frameless registration for temporary modules
2026-09-30 11:00:00 -04:00
Ilia Alshanetsky 3093b9daca Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Zend: Skip frameless registration for temporary modules
2026-09-30 10:59:57 -04:00
Ilia Alshanetsky 75d77cb4fe Zend: Skip frameless registration for temporary modules
dl() modules are MODULE_TEMPORARY. Their function records are freed at
request shutdown, but zend_flf_functions keeps those pointers for the
process lifetime. A later request can match the stale handler address
and use the freed record. Temporary modules leave the frameless info
unset, so the call uses the ordinary internal path.

Closes GH-24008
2026-09-30 10:59:46 -04:00
Gina Peter Banyard 3884053c04 Zend: rename zend_object* parameter to "this_ptr" for zend_call_* functions (#23989)
To be more explicit in what the zend_object* represents.
2026-09-29 16:20:29 +01:00
Gina Peter Banyard cfb1d5ee12 Zend: refactor zend_parse_arg_class() so that it can be reused (#23104)
And stop throwing the exceptions directly, fixing quiet mode handling at the same time.
2026-09-28 14:22:02 +01:00
Noah Webber 5a9d50dc61 Fix typos, grammatical errors, and refactor misspelled local identifiers (#23803)
Correct typographical and grammatical mistakes across docs, comments, and build tools. Refactor local identifiers childrens to children in RecursiveFilterIterator and sav to saved_char in sapi_header_add_op.
2026-09-24 15:56:13 +02:00
Nora Dossche 38956a3f3e Drop unused class_cleanup_handlers (#23696)
This is only ever written to, but never read, and since this is static,
no other translation unit or module can access this too.
2026-09-15 23:02:19 +02:00
eafcd68369 zend_API: Verify property types in object_properties_load() (#23639)
* zend_API: Verify property types in `object_properties_load()`

Fixes php/php-src#9708.

* zend_API: Fix various issues in `object_properties_load()`

Fixes Fixes php/php-src#9707.

Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>

* NEWS

* random: Remove now-obsolete manual `$engine` type check in `Randomizer::__unserialize()`

* zend_API: Make `object_properties_load()` use `strict_types=1`

This is consistent with regular unserialization, which also performs strict
type checking.

Co-authored-by: Gina Peter Banyard <girgias@php.net>

* Block creation of readonly reference properties

Co-authored-by: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com>

---------

Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Co-authored-by: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com>
2026-09-15 20:09:44 +02:00
Gina Peter Banyard b83afc6caf Zend: refactor zend_parse_arg_impl() to return zend_expected_type (#23052)
This effectively mimics part of what Fast ZPP does and allows us to re-use the fast ZPP error APIs
2026-08-24 14:38:18 +01:00
Gina Peter Banyard ee908f5542 Zend: normalise behaviour around class name ZPP specifier (#23359)
Splitting the behavioural change of #23052 out into this and come up with something that is hopefully more sensible and consistent between fast and slow ZPP and the object or class_name Fast ZPP specifier.
2026-08-21 13:31:45 +01:00
Weilin Du d3f0e07df3 Zend: Use pointer hash lookups for methods 2026-08-16 16:35:06 +08:00
Weilin Du 48186fcd4c Zend: Use lowercase hash lookup for duplicate function checks 2026-08-16 16:35:06 +08:00
Weilin Du 2a9416c6f7 Zend: Various refactor with zend_hash_str_find_ptr_lc (#23293)
zend_hash_str_find_ptr_lc is very useful in place we need to deal with lower
case strings. Here we use it to replace the process of first creating the
string, turning it to lower case and freeing it.
2026-08-16 00:12:08 +08:00
Gina Peter Banyard f74acb62a3 Zend: remove zend_is_countable() (#23010)
This function is only used once internally, and no usage is reported from a SourceGraph search. [1]

[1] https://sourcegraph.com/search?q=context:global+-f:zend_API.c+-f:zend_API.h+zend_is_countable&patternType=keyword&sm=0
2026-08-12 13:51:03 +01:00
NickSdot c383b8cae0 core: Deprecate using namespace as class constant name (#22964)
RFC: https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_using_namespace_as_a_class_constant_name
2026-08-10 21:03:40 +01:00
Gina Peter Banyard bad89ea445 Zend: remove zend_parse_parameter() (#23051)
This API is far worse than just using the existing zend_parse_arg_TYPE() APIs.

A SourceGraph search [1] shows this API is effectively only used by ext/ds to which a PR migrating away from this API has been submitted. [2]
The other two usages are from a now deprecated extension [3] and @arnauld-lb's now longer maintained php-go project. [4]

As such we think it is reasonable to remove said API.

[1] https://sourcegraph.com/search?q=context:global+-f:zend_API.c+-f:zend_API.h+zend_parse_parameter%28&patternType=keyword&sm=0
[2] https://github.com/php-ds/ext-ds/pull/232
[3] https://github.com/libvips/php-vips-ext
[4] https://github.com/arnaud-lb/php-go
2026-08-10 18:34:18 +01:00
David Carlier bb0ab98b9d Zend: is_callable() wrongly accepts objects with no get_closure handler.
Fix #23121

zend_is_callable_at_frame() tested `get_closure && get_closure(...) == FAILURE`,
so a NULL handler short circuited past the error branch into the success path,
leaving fcc->function_handler NULL. zend_fcc_addref() then asserted and
call_user_func() dereferenced the null zend_function.

Close GH-23123
2026-08-08 18:50:19 +01:00
Gina Peter Banyard b7c967f67d Zend: remove zend_save_error_handling() (#23011)
This function is only used once internally, and no usage is reported from a SourceGraph search. [1]

[1] https://sourcegraph.com/search?q=context:global+-f:zend_API.c+-f:zend.h+zend_save_error_handling&patternType=keyword&sm=0
2026-08-04 21:01:46 +01:00
Gina Peter Banyard d6b0c761b2 Zend: handle non-string arguments for ZPP class-string specifier as expected (#23001)
* Zend: add tests for ZPP class-string specifier

* Zend: handle non-string arguments for ZPP class-string specifier as expected

This doesn't behave like any of the other specifiers, as it doesn't respect strict_types, emit a deprecation for null, or reject arrays
2026-08-03 17:30:43 +01:00
Gina Peter Banyard bbf82d7a84 Zend: Remove ZPP_ERROR_WRONG_COUNT case
As it is unused, the relevant error is handled before and _error_code is assigned ZPP_ERROR_FAILURE.
2026-08-03 01:56:20 +01:00
Gina Peter Banyard add8d542b6 Zend: use C enum for ZPP error states 2026-08-03 01:56:20 +01:00
Gina Peter Banyard e31d8e082d Zend: move some basic forwarding function definitions to the header (#22936) 2026-08-02 21:14:50 +01:00
Gina Peter Banyard 41b4d43d3e Zend: ZPP use uint32_t type for variable storing result of ZEND_CALL_NUM_ARGS() 2026-08-02 20:19:49 +01:00
Gina Peter Banyard 0dc8a54f62 Zend: move true function search out of main callability check
And rename C function to zend_is_method_callable
2026-07-31 13:56:30 +01:00
Gina Peter Banyard 76e0734ec5 Zend: unify cleanup in zend_is_callable_at_frame() 2026-07-31 13:56:30 +01:00
Gina Peter Banyard af7a6c704a Zend: remove goto in zend_is_callable_at_frame()
But moving the call into the switch statement rather than trying to understand this code flow.
2026-07-31 13:56:30 +01:00