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

1432 Commits

Author SHA1 Message Date
ndossche
bfd66bbdf0 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix compile warnings under GCC 15.2.1 (#21320)
  Updated to version 2026.1 (2026a)
2026-03-02 23:13:40 +01:00
ndossche
210704258a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix compile warnings under GCC 15.2.1 (#21320)
2026-03-02 23:12:48 +01:00
Nora Dossche
583be5a8ca Fix compile warnings under GCC 15.2.1 (#21320)
The compiler now infers constness through string functions.
Adhere to that.
It also now warns about using multiplications in conditions.
2026-03-02 23:12:06 +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
Khaled Alam
d03d69a88a Remove duplicate #include statements (#21085)
* Remove duplicate #include statements across the codebase.

* feat: Restore conditional/unconditional include pairs in lscriu.c
2026-01-30 16:37:13 +01:00
Gina Peter Banyard
668606816f Zend: move class autoloading from SPL to Zend (#21001)
The primary motivation for this change is that this sort of functionality should reside in core and not in an extension.
The reason being is that this causes issues in regard to extension dependencies and resolution,
something that prevents GH-14544.
2026-01-28 01:57:30 +00:00
Niels Dossche
d766a73c06 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix nightly failure due to OnChangeMemoryLimit changes (#20450)
2025-11-11 13:41:04 +01:00
Niels Dossche
ee9773bdc6 Fix nightly failure due to OnChangeMemoryLimit changes (#20450) 2025-11-11 13:40:04 +01:00
Ilija Tovilo
4227106f37 Merge branch 'PHP-8.5'
* PHP-8.5:
  Commit the actual fix for GH-17951
2025-11-11 01:45:29 +01:00
manuel
9b752a3d2b Commit the actual fix for GH-17951
Sorry, my (ilutov's) bad. I reverted the change to verify the test, but forgot
to undo before pushing.
2025-11-11 01:44:50 +01:00
Gina Peter Banyard
cf96153153 main.c: do not use printf variant if not needed (#20418) 2025-11-08 17:26:21 +00:00
Arnaud Le Blanc
ef9a89f7ec Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-19480: error_log php.ini cannot be unset when open_basedir is configured
2025-09-19 18:13:55 +02:00
Arnaud Le Blanc
938226083e Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19480: error_log php.ini cannot be unset when open_basedir is configured
2025-09-19 14:16:48 +02:00
Niels Dossche
7a1bb71127 Fix GH-19480: error_log php.ini cannot be unset when open_basedir is configured
Since the ini message handlers already check for basedir, we need to
drop the basedir check from ini_set. Then we also fix the exceptional
case for the empty string: it should bypass the basedir check.
Furthermore, there was a regression introduced with the error_log
"syslog" check in ddfe269a (inverted check), so we fix that as well.

Closes GH-19487
2025-09-19 14:14:53 +02:00
Alexandre Daubois
3f66cbeb4d Use zend_string API for mail.cr_lf_mode validation (#19759) 2025-09-09 10:18:42 +02:00
Alexandre Daubois
ae7def78fb Fix GH-19188: Add support for new INI mail.cr_lf_mode (#19238) 2025-09-08 09:58:27 +02:00
Tim Düsterhus
b27d91993d main: Change the register_argc_argv INI default to Off (#19473)
This partly implements the deprecation of the `register_argc_argv` INI setting
by updating the default value to ensure safe behavior when no INI file is
loaded. The actual deprecation warning will follow separately.

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_register_argc_argv_ini_directive
2025-08-28 17:39:55 +02:00
Gina Peter Banyard
f4e2e91d4b core: Remove disable_classes INI setting
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#remove_disable_classes_ini_setting

This took longer to merge than expected but the initial motivation from 2 years ago still applied:

As described in the email to the PHP internals list [1] this feature is fundamentally broken and pointless.

Only internal classes can be disable which brings the following observation. On a minimal build of PHP, with only the mandatory extensions enabled, there are 148 classes/interfaces/traits defined. [2]

Other than the SPL ones (and even then), disabling any of these classes will cause issues within the engine.
Moreover, the SPL ones are not a security concern.

Therefore, any other class that can be disabled must come from an extension that can be disabled altogether. And "disabling" a class from an extension without disabling said extension will render it useless anyway.

If a hosting provided is concerned about an extension, then it should not enable it in the first place. Not break it ad hoc.

Considering the above, I cannot see how this functionality was ever useful.

This is in stark contrast to the disable_functions INI setting, which can be used to selectively remove functionality of an extension without breaking it overall.

What makes this setting particularly broken is that it does not unregister the class, it only overwrites the create CE handler to emit a warning and purge the properties and function hashtables. This leads to various use after free, segfaults, and broken expectations for the engine and extensions which define said classes. On top of that, it is possible to actually instantiate such a class (and even classes which actually disallow this like ext/imap) in userland, and pass it to function that are typed against said class without raising a TypeError. However, when trying to do anything with said object stuff is going to explode in countless ways.

[1] https://news-web.php.net/php.internals/120896
[2] https://gist.github.com/Girgias/63d55ba1e50b580412b004046daed02b
2025-08-25 21:16:55 +01:00
Jorg Adam Sowa
d6d0a2a217 remove safe_mode leftovers (#19552) 2025-08-24 03:55:15 +01:00
Alexandre Daubois
a84a82ed88 Deprecate disabling report_memleaks INI directive (#19481)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_report_memleaks_ini_directive
2025-08-16 14:04:34 +02:00
Arnaud Le Blanc
b7ac56822d Fix build 2025-08-06 19:50:11 +02:00
Arnaud Le Blanc
3ddbad9589 Allocate a fast thread-safe-resource id for opcache
Closes GH-19347
2025-08-06 18:02:43 +02:00
Gina Peter Banyard
d9000b3094 tree: replace some unnecessary uses of spprintf (#19354) 2025-08-05 17:25:47 +01:00
Ilija Tovilo
cd80ed6f7b Implement changes to GH-17951 according to ML discussion 2025-08-04 16:04:25 +02:00
Frederik Milling Pytlick
4e21924271 Fix GH-17951: Addition of max_memory_limit INI
Closes GH-18011
2025-08-04 16:04:25 +02:00
Gina Peter Banyard
a66b631bce main/php_ini: various minor refactorings (#19339) 2025-08-03 17:30:12 +01:00
Gina Peter Banyard
961412d6f2 main: refactor implementation of set_time_limit() (#19338) 2025-08-03 16:17:00 +01:00
Gina Peter Banyard
105c1e9896 tree: use zend_str_has_nul_byte() API (#19336) 2025-07-31 23:57:27 +01:00
Arnaud Le Blanc
c561f7da85 Refresh zend_mm shadow key on fork
The shadow key is refreshed when resetting the memory manager between two
requests. But in forking SAPIs the first request of a child process inherits the
shadow key of the parent. As a result, a leak of the shadow key during the first
request of one process gives away the shadow key used during the first request
of other processes. This makes the key refresh mechanism less useful.

Here I ensure that we refresh the shadow key after a fork. We can not reset the
manager as there may be active allocations. Instead, we have to recompute shadow
pointers with the new key.

Closes GH-16765
2025-07-29 14:00:37 +02:00
DanielEScherzer
e98879f19c main.c: fix a typo, add some capitalization [skip ci] (#18905) 2025-06-26 10:52:33 -07:00
Niels Dossche
33ae76405f Use zend_string for arg_separators
This allows us to avoid a call to `zend_ini_str` which took 6% of the
profile on my i7-4790 for a call to `http_build_query`. Now we can just
grab the value from the globals.
In other files this can avoid some length recomputations.
2025-05-21 19:54:09 +02:00
Tim Düsterhus
5dd9b0dcef Add php_build_provider() (#18168)
* Add `ZEND_ATTRIBUTE_CONST` to php_version() and php_version_id()

* Add `php_build_provider()`

* Use `php_build_provider()` internally
2025-03-29 13:29:40 +01:00
Niels Dossche
867ed156f7 Fix GH-18033: NULL-ptr dereference when using register_tick_function in destructor
The problem is that `php_request_shutdown` calls `php_deactivate_ticks` prior
to running destructors and the shutdown functions and finalizing output
handlers.
So if a destructor or shutdown function re-registers a tick function,
then the user tick functions handler will be added back to `PG(tick_functions)`.
When the next request happens, the list `PG(tick_functions)` still contains an
entry to call the user tick functions (added in the previous request
during shutdown). This causes a NULL deref eventually because
`run_user_tick_functions` assumes that if it is called then
`BG(user_tick_functions)` must be non-NULL.

Fix this by moving the tick handler deactivation.

Closes GH-18047.
2025-03-15 00:32:10 +01:00
Eric Norris
0a14ab18d2 RFC: Error Backtraces v2 (#17056)
see https://wiki.php.net/rfc/error_backtraces_v2

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-01-29 12:54:23 +01:00
Christoph M. Becker
1675d32261 Fix printf style issues in Windows specific code (GH-17452)
A couple of calls pass strings as formats (`-Wformat-security`), and
some others mix up types (`-Wformat`).
2025-01-13 11:50:05 +01:00
Christoph M. Becker
ba6c00505d Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16849: Error dialog causes process to hang
2024-11-25 23:09:36 +01:00
Christoph M. Becker
4c5710579a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16849: Error dialog causes process to hang
2024-11-25 23:09:13 +01:00
Christoph M. Becker
929d42de50 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16849: Error dialog causes process to hang
2024-11-25 23:08:11 +01:00
Christoph M. Becker
e75061b512 Fix GH-16849: Error dialog causes process to hang
If `_DEBUG` is set, assertion failures and errors are directed to a
debug message window by default[1].  That causes a process to hang,
since these dialogs are modal.  While we already cater to assertion
failures, errors have apparently been overlooked.

We choose a minimal fix for BC reasons; although passing `0` as
`reportMode` is undocumented, it obviously works fine for a long time.
We may consider to improve on this for the `master` branch.

[1] <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode>

Closes GH-16850.
2024-11-25 23:04:51 +01:00
Christoph M. Becker
6dec6a6dba Add PHP_BUILD_DATE constant
This information can be occasionally useful, and would otherwise need
to be parsed from `phpinfo()` output.

However, maybe more importantly we unify the build date between what is
given by `php -v` and `php -i`, since these compilation units are not
necessarily preprocessed within the same second.

Closes GH-16747.
2024-11-18 20:53:28 +01:00
Jakub Zelenka
10d2d862a6 Merge branch 'PHP-8.3' into PHP-8.4 2024-10-06 19:43:19 +01:00
Jakub Zelenka
59816b9a73 Merge branch 'PHP-8.2' into PHP-8.3 2024-10-06 19:40:24 +01:00
Jakub Zelenka
5a47f27021 Fix GH-15395: php-fpm: zend_mm_heap corrupted with cgi-fcgi request
Closes GH-16227

Co-authored-by: David Carlier <devnexen@gmail.com>
2024-10-06 19:37:55 +01:00
Michael Voříšek
d313ad6098 Deprecate E_STRICT constant and remove error level
RFC: https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant

Closes GH-13053
2024-09-18 14:33:14 +02:00
Bob Weinand
25d761623c Make internal run_time_cache a persistent allocation (#15040)
We also add zend_map_ptr_static, so that we do not incur the overhead of constantly recreating the internal run_time_cache pointers on each request.
This mechanism might be extended for mutable_data of internal classes too.
2024-09-07 01:45:26 +02:00
Niels Dossche
0d616d1b82 Fix GH-15693: Unnecessary include in main.c bloats binary
Closes GH-15700.
2024-09-02 21:54:13 +02:00
Calvin Buckley
afc5738154 Show build provider and unify version information printing (#14657)
* Show build provider information in "php -v"

Vendors such as distributions can set the `PHP_BUILD_PROVIDER`
variable, that gets printed in phpinfo. However, I find that users check
`php -v` more often than phpinfo to see what PHP they're running. The
problem with this is that it does not show that build provider
information.

This change makes the build provider information printed on an
additional line of the version information.

* Put on same line so it works with or without env var

Unbreaks build without PHP_BUILD_PROVIDER set.

* change wording in provider version text

better grammatically; many different possibilities here though

* Unify SAPI version printing

This makes it so that all of the SAPIs share the same code for printing
version information. This is useful in case of any future changes to the
version information, such as i.e. adding build provider to the output.

* Make include for php_print_version explicit

* Preserve phpdbg version and output channel

php_printf doesn't have same semantics, as phpdbg_out could be on a
different output than stdout/err. Also add the phpdbg version (in case
it differs from PHP's, to keep similar output before this PR)

* remove size variables

we don't use them and CI doesn't like unused variables

* Fix format string insecurity
2024-08-12 23:24:41 -03:00
David CARLIER
2aeff2c988 main: update Winsock api version to 2.2 (#14909)
not been updated since php 4 whereas 2.2 is available even in Win2000.
2024-07-17 14:17:29 +01:00
Arnaud Le Blanc
ff58a7f624 Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] NEWS for GH-13922
  [ci skip] NEWS for GH-13922
  Support sysconf(_SC_GETPW_R_SIZE_MAX) == -1 (#13922)
2024-06-24 19:57:28 +02:00
Arnaud Le Blanc
b1119de0c9 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS for GH-13922
  Support sysconf(_SC_GETPW_R_SIZE_MAX) == -1 (#13922)
2024-06-24 19:56:19 +02:00