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

2448 Commits

Author SHA1 Message Date
Peter Kokot
f99ca6347f Windows build: Use GREP_HEADER() instead of CHECK_FUNC_IN_HEADER() (#21315)
This removes the following unused compile definitions:

- HAVE_OSSL_SET_MAX_THREADS
- HAVE_ARGON2ID_HASH_RAW

The CHECK_FUNC_IN_HEADER() function defines the 'HAVE_<FUNCTION>'
compile definitions to 0 or 1, but these aren't used in the code.
Defining such preprocessor macros makes it difficult to track and sync
with other build systems.
2026-03-06 14:11:20 +01:00
Alexandre Daubois
11a95749b1 Convert more zend_parse_parameters_none() to fast ZPP (#21330) 2026-03-04 14:07:46 +01: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
Peter Kokot
4fbe41116b Enable all warnings for re2c (#19051)
This helps noticing issues like GH-17204 and GH-17523 sooner.
2026-02-13 17:43:35 +01:00
Arshid
51158bbe90 [win32] Use RETURN_BOOL() in sapi_windows_set_ctrl_handler() (GH-21148) 2026-02-06 10:09:40 +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
Weilin Du
4f793ba1c3 [skip ci] Fix duplicate words typos (GH-20800) 2025-12-31 02:22:09 +01:00
Gina Peter Banyard
77d306ef38 win32/sendmail.c/PostHeader(): refactor function
Input as zend_string
Use smart_str to concatenate strings
Change return type to bool
2025-12-27 00:36:26 +00:00
Gina Peter Banyard
fc276aee68 win32/sendmail.c/SendText(): use zend_string for stripped_headers
This prevents some copying and is in preparation of other refactoring preventing strlen() recomputations
2025-12-27 00:36:26 +00:00
Gina Peter Banyard
8aa64bb976 win32/sendmail.c/SendText(): move posting of DATA prior to stripped header computation
Removes some error handling and work if it fails
2025-12-27 00:36:26 +00:00
Gina Peter Banyard
004c630106 win32/sendmail.c/addToHeader(): voidify function
It always returns 1 and thus a bunch of error handling code is useless
2025-12-27 00:36:26 +00:00
Gina Peter Banyard
6bd9c555ee win32/sendmail.c/SendText(): move string duplication code to a more logical place 2025-12-27 00:36:26 +00:00
Gina Peter Banyard
f1a8944fcd win32/sendmail.c/SendText(): use zend_string* for headers{_lc} parameters
This prevents some strlen() reconputations
2025-12-27 00:36:26 +00:00
Gina Peter Banyard
84e63bfd9b win32/sendmail.c/php_win32_mail_trim_header(): use ZSTR_INIT_LITERAL() 2025-12-27 00:36:26 +00:00
Gina Peter Banyard
4431aa94b7 win32/sendmail.c: remove mailCc parameter that is always NULL 2025-12-27 00:36:26 +00:00
Gina Peter Banyard
0e19bc1bfd win32/sendmail.c: remove mailBbc parameter that is always NULL 2025-12-27 00:36:26 +00:00
Gina Peter Banyard
6f28370d2f win32/sendmail.c: remove mailRPath parameter that is always NULL 2025-12-27 00:36:26 +00:00
Gina Peter Banyard
4dad723c41 win32/sendmail.c/Post(): refactor function
Change return type to bool as it only ever returns two values
2025-12-27 00:36:26 +00:00
Gina Peter Banyard
7e8c636b30 win32/sendmail.c: mark error messages array as const 2025-12-27 00:36:26 +00:00
Daniel Scherzer
a4c712c379 master is now for PHP 8.6.0-dev 2025-09-23 14:59:55 -04:00
Shivam Mathur
e408bcafb2 Fix early exit condition in phpize.bat (#19886) 2025-09-19 17:32:34 +05:30
Dylan K. Taylor
36057b93f3 Fix GH-19722: Windows: _get_osfhandle asserts in debug mode when given a socket
Closes GH-19725.
2025-09-10 17:50:03 +02:00
Peter Kokot
f4f6e89a1a GH-15630 follow-up: Remove redundant undefs (#19783) 2025-09-10 15:14:16 +02:00
Arnaud Le Blanc
7b3e68ff69 Fix error handling inconsistency with opcache
When opcache is enabled, error handling is altered in the following ways:

 * Errors emitted during compilation bypass the user-defined error handler
 * Exceptions emitted during class linking are turned into fatal errors

Changes here make the behavior consistent regardless of opcache being enabled or
not:

 * Errors emitted during compilation and class linking are always delayed and
   handled after compilation or class linking. During handling, user-defined
   error handlers are not bypassed. Fatal errors emitted during compilation or
   class linking cause any delayed errors to be handled immediately (without
   calling user-defined error handlers, as it would be unsafe).
 * Exceptions thrown by user-defined error handlers when handling class linking
   error are not promoted to fatal errors anymore and do not prevent linking.

Fixes GH-17422.
Closes GH-18541.
Closes GH-17627.

Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
2025-07-27 11:01:49 +02:00
Peter Kokot
aa366b5113 Update re2c minimum versions in Windows checks and docs (#19039) 2025-07-07 07:54:29 +02:00
Peter Kokot
93e3aca5fa Remove HAVE_INTMAX_T and SIZEOF_INTMAX_T (#18971)
The intmax_t is a C99 standard type defined in `<stdint.h>` and widely
available on current platforms. On Windows they are available as of
Visual Studio 2013. Using it conditionally as in these occurrences is
not needed anymore.
2025-06-29 19:50:27 +02:00
Peter Kokot
fffe642d67 Remove HAVE_PTRDIFF_T and SIZEOF_PTRDIFF_T (#18968)
The ptrdiff_t is a C89 standard type defined in `<stddef.h>` and widely
available on current platforms. Using it conditionally as in these
occurrences is not needed anymore.
2025-06-28 20:16:12 +02:00
Peter Kokot
3df665a888 [Windows build] Remove redundant flags definitions (#18890)
The /d2FuncCache1 compile option is already added by
toolset_setup_common_cflags() in confutils.js to all targets.

ZEND_DVAL_TO_LVAL_CAST_OK was removed in
3725717de1.
2025-06-22 15:19:08 +02:00
Peter Kokot
3ff6874658 Remove HAVE_GETLOGIN from win32/config.w32.h.in template (#18865)
PHP once had getlogin() emulation implemented on Windows. This isn't the
case anymore since 2006 (dc34d34230),
neither Windows has getlogin() function.
2025-06-19 14:07:40 +02:00
Calvin Buckley
76791e90b9 Use win32 glob implementation on all platforms (#18164)
* Move glob to main/ from win32/

In preparation to make the Win32 reimplementation the standard
cross-platform one. Currently, it doesn't do that and just passes
through the original glob implementation. We could consider also having
an option to use the standard glob for systems that have a sufficient
one.

* Enable building with win32 glob on non-windows

Kind of broken. We're namespacing the function and struct, but not yet
the GLOB_* defines. There are a lot of places callers check if i.e.
NOMATCH is defined that would likely become redundant.

Currently it also has php_glob and #defines glob php_glob (etc.) - I
suspect doing the opposite and changing the callers would make more
sense, just doing MVP to geet it to build (even if it fails tests).

* Massive first pass at conversion to internal glob

Have not tested yet. the big things are:

- Should be invisible to userland PHP code.
- A lot of :%s/GLOB_/PHP_GLOB_/g; the diff can be noisy as a result,
  especially in comments.
- Prefixes everything with PHP_ to avoid conflicts with system glob in
  case it gets included transitively.
- A lot of weird shared definitions that were sprawled out to other
  headers are now included in php_glob.h.
- A lot of (but not yet all cases) of HAVE_GLOB are removed, since we
  can always fall back to php_glob.
- Using the system glob is not wired up yet; it'll need more shim
  ifdefs for each flag type than just glob_t/glob/globfree defs.

* Fix inclusion of GLOB_ONLYDIR

This is a GNU extension, but we don't need to implement it, as the GNU
implementation is flawed enough that callers have to manually filter it
anyways; just provide a stub definition for the constant.

We could consideer implementing this properly later. For now, fixes the
basic glob constant tests.

* Remove HAVE_GLOBs

We now always have a glob implementation that works. HAVE_GLOB should
only be used to check if we have a system implementation, for if we
decide to wrap the system implementation instead.

* We don't need to care about being POSIXly correct for internal glob

* Check for reallocarray

Ideally temporary until GH-17433.

* Forgot to move this file from win32/ to main/

* Check for issetugid (BSD function)

* Allow using the system glob with --enable-system-glob

* Style fix after removing ifdef

* Remove empty case for system glob
2025-05-20 16:20:59 -03:00
Ilija Tovilo
905bba637a Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix missing include in win32/globals.c
2025-05-06 15:52:38 +02:00
Ilija Tovilo
14ff4b75a2 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix missing include in win32/globals.c
2025-05-06 15:52:30 +02:00
Ilija Tovilo
69f0882d3b Fix missing include in win32/globals.c
This previously errored with:

win32\globals.c(66): error C2220: the following warning is treated as an error
win32\globals.c(66): warning C4013: 'php_win32_signal_ctrl_handler_request_shutdown' undefined; assuming extern returning int

This only errors on master because of 2473f57ba (thanks to Niels for
that info!).

Closes GH-18508
2025-05-06 15:51:37 +02:00
Niels Dossche
3c84b01e02 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix leak+crash with sapi_windows_set_ctrl_handler()
2025-05-05 19:14:19 +02:00
Niels Dossche
d4a3e437ae Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix leak+crash with sapi_windows_set_ctrl_handler()
2025-05-05 19:14:13 +02:00
Niels Dossche
fb3536fd60 Fix leak+crash with sapi_windows_set_ctrl_handler()
The ctrl_handler is never destroyed. We have to destroy it at request
end so we avoid leaking it and also avoid keeping a reference to
previous request memory in a next request. The latter can result in a
crash and can be demonstrated with this script and `--repeat 2`:

```php
class Test {
	public function set() {
		sapi_windows_set_ctrl_handler(self::cb(...));
	}
	public function cb() {
	}
}

$test = new Test;
$test->set();
sleep(3);
```
When you hit CTRL+C in the second request you can crash.

This patch resolves both the leak and crash by destroying the
ctrl_handler after a request.

Closes GH-18231.
2025-05-05 19:13:39 +02:00
Niels Dossche
864ad1b5bb Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18136: tracing JIT floating point register clobbering on Windows and ARM64
2025-04-21 13:15:50 +02:00
Niels Dossche
1a1a83f1fc Fix GH-18136: tracing JIT floating point register clobbering on Windows and ARM64
On win64, xmm6-xmm15 are preserved registers, but the prologues and
epilogues of JITted code don't handle these. The issue occurs when
calling into the JIT code again via an internal handler
(like call_user_func). Therefore, we want to save/restore xmm registers
upon entering/leaving execute_ex. Since MSVC x64 does not support inline
assembly, we create an assembly wrapper around the real execute_ex
function.
The alternative is to always save/restore these xmm registers into the
fixed call frame, but this causes unnecessary overhead.
The same issue occurs for ARM64 platforms for floating point register
8 to 15. However, there we can use inline asm to fix this.

Closes GH-18352.
2025-04-21 13:15:43 +02:00
Christoph M. Becker
e9ffe02fa1 Merge branch 'PHP-8.4'
* PHP-8.4:
  [skip ci] Fix phpize for Windows 11 (24H2)
2025-02-14 17:19:50 +01:00
Christoph M. Becker
974ed3130e Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Fix phpize for Windows 11 (24H2)
2025-02-14 17:19:18 +01:00
Christoph M. Becker
302165837f Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Fix phpize for Windows 11 (24H2)
2025-02-14 17:17:51 +01:00
Christoph M. Becker
595e616292 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [skip ci] Fix phpize for Windows 11 (24H2)
2025-02-14 17:16:04 +01:00
Bob Weinand
7f6c05116e [skip ci] Fix phpize for Windows 11 (24H2)
It seems like n === undefined must have worked on older versions of
jscript, but currently it just causes the insertion to silently fail.
This sets n to an empty string, allowing phpize to include the local
config.w32 files.
2025-02-14 17:15:24 +01:00
Christoph M. Becker
107bd080a5 Fix Clang style nits (GH-17685)
This addresses all `-Wlogical-op-parentheses` and `-Wmissing-braces`
warnings across the whole code base (all Windows specific code).
2025-02-05 14:13:56 +01:00
Christoph M. Becker
4e6a3cecf5 Don't forward declare static functions in sendmail.h (GH-17684)
sendmail.h is not only included by sendmail.c, but also by
php_win32_globals.h, because that header uses some of the defined
macros.  However, the forward declarations of the static functions are
not needed anywhere else than in sendmail.c, and Clang warns about the
unused functions elsewhere (`-Wunused-function`).  Thus we move the
forward declarations to sendmail.c.
2025-02-03 16:50:32 +01:00
Christoph M. Becker
3fa9e283a0 Drop unused local variables (GH-17682) 2025-02-03 16:42:29 +01:00
Christoph M. Becker
caf5e8a167 Solve C4267 warnings in win32/ioutil for x64 (GH-17674)
C4267[1] are about conversion from `size_t` to a "smaller" type,
causing potential loss of data (aka. truncation).

In this case we can solve that cleanly (i.e. without casting and
further checks) by changing the affected variables to be of type
`DWORD`.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4267>
2025-02-03 00:13:58 +01:00
Shivam Mathur
0d8aebf1d9 Fix condition to check for config.w32 in phpize (#17667) 2025-02-02 08:49:16 +05:30
Christoph M. Becker
f1702d2bb1 Suppress MSVC C4995 warnings (deprecations)
These have the same meaning as C4996[1] (which we already suppress),
but are triggered by a different mechanism[2].  It makes no sense to
suppress one, but not both.

Of course it would be better not to suppress either, but wrt the two
C4995 warnings we see in php-src, that requires deprecation of using
the ODBC cursor library[3], so might take a while.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996>
[2] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4995>
[3] <https://externals.io/message/126264>

Closes GH-17664.
2025-02-01 22:48:43 +01:00
Christoph M. Becker
236e12e5f0 Drop --with-uncritical-warn-choke configuration option
This selection of suppressed warnings is pretty arbitrary, and
apparently disabling it does not raise any more warning for whole
php-src (except for `-Wno-deprecated-declarations`).  As such it
appears to be pretty useless, and it seems to be more appropriate to
let users select which warnings to suppress via manually set `CFLAGS`.

Since we already apply `/wd4996`[1] when building with MSVC, and there
are indeed plenty of deprecation warnings, for now, we apply
`-Wno-deprecated-declarations` for Clang builds unconditionally.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996>

Closes GH-17554.
2025-02-01 15:09:40 +01:00