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

1697 Commits

Author SHA1 Message Date
ndossche
4b0a4f47f3 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-20906: Assertion failure when messing up output buffers
2026-02-27 18:15:26 +01:00
ndossche
38421684c1 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-20906: Assertion failure when messing up output buffers
2026-02-27 18:15:20 +01:00
ndossche
1709689256 Fix GH-20906: Assertion failure when messing up output buffers
Closes GH-20908.
2026-02-27 18:14:56 +01:00
Gina Peter Banyard
542175ecfa ext/standard: mark ext/random as a required dependency (#21130)
As the shuffle() and array_rand() functions use part of the Random API
2026-02-05 16:09:54 +00: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
David CARLIER
ce798afac3 Fix GH-21058: error_log() crash on null destination argument. (#21064)
we preserve the lower branches behavior by letting php_stream_open_wrapper_ex
handling the null path and propagating the exception.

close GH-21064
2026-01-29 19:49:45 +00:00
Jordi Kroon
51b1aa160d Fix GH-20858: null pointer dereference in php_mail_detect_multiple_crlf via error_log
close GH-20862
2026-01-10 00:51:25 +00:00
Gina Peter Banyard
8727816734 ext/standard: use RETURN_BOOL() when possible 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
Jakub Zelenka
5c0a6feca2 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Update NEWS with info about security issues
  Fix GHSA-www2-q4fc-65wf
  Fix GHSA-h96m-rvf9-jgm2
  Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
  Fix GH-20584: Information Leak of Memory
2025-12-16 15:36:52 +01:00
Jakub Zelenka
633fb48fca Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Update NEWS with info about security issues
  Fix GHSA-www2-q4fc-65wf
  Fix GHSA-h96m-rvf9-jgm2
  Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
  Fix GH-20584: Information Leak of Memory
2025-12-16 15:35:25 +01:00
Jakub Zelenka
e776695abf Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Update NEWS with info about security issues
  Fix GHSA-www2-q4fc-65wf
  Fix GHSA-h96m-rvf9-jgm2
  Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
  Fix GH-20584: Information Leak of Memory
2025-12-16 15:34:19 +01:00
Jakub Zelenka
6e124d0df6 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Update NEWS with info about security issues
  Fix GHSA-www2-q4fc-65wf
  Fix GHSA-h96m-rvf9-jgm2
  Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
  Fix GH-20584: Information Leak of Memory
2025-12-16 15:30:54 +01:00
Niels Dossche
ed70b1ea43 Fix GHSA-www2-q4fc-65wf 2025-12-16 15:26:59 +01: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
Tim Düsterhus
ae1438b5e5 uri/standard: Move the parse_url() URI parser into ext/uri/ (#19587)
* uri/standard: Move the `parse_url()` URI parser into ext/uri/

Making ext/standard depend on ext/uri/ is a bit iffy (given that it is called
*standard*) and having the parser implementation in ext/uri/ makes it easier to
find and keep in sync.

* uri: Mark local pointers as `const` in uri_parser_php_parse_url.c

* uri: Remove useless explicit cast from void in uri_parser_php_parse_url.c

* uri: Properly prefix symbols in uri_parser_php_parse_url.[ch]

* uri: Remove useless `throw_invalid_uri_exception()` helper in uri_parser_php_parse_url.c
2025-08-26 14:49:42 +02: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
Niels Dossche
8db883c540 Add API to register custom image handlers
This is modelled similarly to the password registry API.
We have an array to which new handlers can be added, and when a built-in
handler cannot handle the image, we try the handlers in the array.
The standard module is in control of registering a new constant for the
image file type so that no clashes can occur. It also updates the image
file type count constant. As such, the registration may only happen
during module startup.
2025-07-20 12:53:57 +02:00
Niels Dossche
6cc21c4ee6 Optimize pack()
Instead of using lookup tables, we can use a combination of shifts and
byte swapping to achieve the same thing in less cycles and with less
code.

Benchmark files
---------------

pack1.php:
```php
for ($i = 0; $i < 10_000_000; ++$i) {
    pack("J", 0x7FFFFFFFFFFFFFFF);
}
```

pack2.php:
```php
for ($i = 0; $i < 4000000; ++$i) {
    pack("nvc*", 0x1234, 0x5678, 65, 66);
}
```

On an i7-4790:
```
Benchmark 1: ./sapi/cli/php pack1.php
  Time (mean ± σ):     408.8 ms ±   3.4 ms    [User: 406.1 ms, System: 1.6 ms]
  Range (min … max):   403.6 ms … 413.6 ms    10 runs

Benchmark 2: ./sapi/cli/php_old pack1.php
  Time (mean ± σ):     451.7 ms ±   7.7 ms    [User: 448.5 ms, System: 2.0 ms]
  Range (min … max):   442.8 ms … 461.2 ms    10 runs

Summary
  ./sapi/cli/php pack1.php ran
    1.11 ± 0.02 times faster than ./sapi/cli/php_old pack1.php

Benchmark 1: ./sapi/cli/php pack2.php
  Time (mean ± σ):     239.3 ms ±   6.0 ms    [User: 236.2 ms, System: 2.3 ms]
  Range (min … max):   233.2 ms … 256.8 ms    12 runs

Benchmark 2: ./sapi/cli/php_old pack2.php
  Time (mean ± σ):     271.9 ms ±   3.3 ms    [User: 269.7 ms, System: 1.3 ms]
  Range (min … max):   267.4 ms … 279.0 ms    11 runs

Summary
  ./sapi/cli/php pack2.php ran
    1.14 ± 0.03 times faster than ./sapi/cli/php_old pack2.php
```

On an i7-1185G7:
```
Benchmark 1: ./sapi/cli/php pack1.php
  Time (mean ± σ):     263.7 ms ±   1.8 ms    [User: 262.6 ms, System: 0.9 ms]
  Range (min … max):   261.5 ms … 268.2 ms    11 runs

Benchmark 2: ./sapi/cli/php_old pack1.php
  Time (mean ± σ):     303.3 ms ±   6.5 ms    [User: 300.7 ms, System: 2.3 ms]
  Range (min … max):   297.4 ms … 318.1 ms    10 runs

Summary
  ./sapi/cli/php pack1.php ran
    1.15 ± 0.03 times faster than ./sapi/cli/php_old pack1.php

Benchmark 1: ./sapi/cli/php pack2.php
  Time (mean ± σ):     156.7 ms ±   2.9 ms    [User: 154.7 ms, System: 1.7 ms]
  Range (min … max):   151.6 ms … 164.7 ms    19 runs

Benchmark 2: ./sapi/cli/php_old pack2.php
  Time (mean ± σ):     174.6 ms ±   3.3 ms    [User: 171.9 ms, System: 2.3 ms]
  Range (min … max):   170.7 ms … 180.4 ms    17 runs

Summary
  ./sapi/cli/php pack2.php ran
    1.11 ± 0.03 times faster than ./sapi/cli/php_old pack2.php
```

Closes GH-18524.

Co-authored-by: divinity76 <divinity76@gmail.com>
2025-07-07 22:28:12 +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
Niels Dossche
c0da1bc44d Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17403: Potential deadlock when putenv fails
2025-04-24 20:22:35 +02:00
Niels Dossche
c6ed104e91 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17403: Potential deadlock when putenv fails
2025-04-24 20:22:30 +02:00
Niels Dossche
32e091260a Fix GH-17403: Potential deadlock when putenv fails
Closes GH-18368.
2025-04-24 20:22:04 +02:00
Jakub Zelenka
916528e3f5 Merge branch 'PHP-8.4' 2025-03-27 11:38:17 +01:00
Jakub Zelenka
6cf24cd47c Merge branch 'PHP-8.3' into PHP-8.4 2025-03-27 11:37:12 +01:00
Jakub Zelenka
2197a490f7 Fix GH-18145: basic_globals_ctor initialization
This resets all basic globals during ctor and just modifies the ones
with a special value. It also switches to using basic_globals_p which
what should be used in this context.

Closes GH-18156
2025-03-27 11:35:55 +01:00
DanielEScherzer
a1da7cac85 basic_functions: update error_log documentation [skip ci] (#17828)
Sending to a TCP/IP address is not an option anymore, and it hasn't been since
before the file was created in this repo in 1999 (257de2b). Based on
php/doc-en@d522d135a1 it appears that this
feature was part of PHP 3 and removed before PHP 4. I tried to track down the
original code to find when it was actually removed but wasn't able to find a
PHP 3 repository.
2025-02-16 10:22:18 +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
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
Gina Peter Banyard
6ab38b52d3 ext/standard: Refactor tick and shutdown functions
Remove usage of FCI and store the parameters and count of it directly on the relevant structures
This reduces the size of the structs by ~50
2024-12-29 23:41:06 +00:00
Gina Peter Banyard
72ff9077a5 ext/standard: Let is_numeric_str parse the int value for us in getopt() 2024-12-29 18:36:11 +00:00
Gina Peter Banyard
f3655100b8 ext/standard: Reuse computed strlen() value in getopt() 2024-12-29 18:36:11 +00:00
Gina Peter Banyard
a718110ae0 ext/standard: Use zend_string in ini_get_all() 2024-12-29 18:36:11 +00:00
Gina Peter Banyard
a1cb516817 ext/standard: Use zend_string in move_uploaded_file()
Also check that the initial path does not contain null bytes
2024-12-29 18:36:11 +00:00
Gina Peter Banyard
1e3498ea01 ext/standard: Use zend_string in is_uploaded_file() 2024-12-29 18:36:11 +00:00
Gina Peter Banyard
1c129c723d ext/standard: Use zend_string in get_include_path() 2024-12-29 18:36:11 +00:00
Gina Peter Banyard
63f6251812 ext/standard: Use zend_string_equals_literal API (#17292)
Instead of a custom one only available in this file
2024-12-29 10:54:17 +00:00
Ilija Tovilo
fb257ee83c Upgrade master to Ubuntu 24.04 (GH-16704) 2024-11-07 16:32:45 +01:00
Ilija Tovilo
6ed730eb59 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix MSAN getservbyport() false positive
  Fix uninitialized CG(zend_lineno)
  Fix uninitialized EG(user_error_handler_error_reporting)
2024-09-09 19:35:09 +02:00
Ilija Tovilo
a5bd4ccb8c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix MSAN getservbyport() false positive
  Fix uninitialized CG(zend_lineno)
  Fix uninitialized EG(user_error_handler_error_reporting)
2024-09-09 19:35:00 +02:00
Ilija Tovilo
0faa1d2017 Fix MSAN getservbyport() false positive
Closes GH-15814
2024-09-09 19:34:43 +02:00
Gina Peter Bnayard
5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard
e7c4d54d65 Use new helper function for "cannot be empty" ValueErrors 2024-08-21 21:12:17 +01:00
Tim Düsterhus
5905857fd2 RFC: Add the RoundingMode enum (#14833)
see https://wiki.php.net/rfc/correctly_name_the_rounding_mode_and_make_it_an_enum

Co-authored-by: Saki Takamachi <saki@php.net>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2024-07-18 20:44:30 +02:00
David Carlier
c14fa48526 Merge branch 'PHP-8.3' 2024-07-06 20:44:47 +01:00
David Carlier
0b28914a26 Merge branch 'PHP-8.2' into PHP-8.3 2024-07-06 20:44:20 +01:00
David Carlier
237518763f Fix GH-14774 time_sleep_until overflow. 2024-07-06 20:43:59 +01:00
Peter Kokot
cf3b9fca8f Sync #if/ifdef/defined (-Wundef) (#14623)
These are either define (to value 1) or undefined:
- __GNUC__
- DBA_CDB_BUILTIN
- DBA_GDBM
- HAVE_FORK
- HAVE_PUTENV
- HAVE_SETENV
- HAVE_SYS_SELECT_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_WAIT_H
- HAVE_UNSETENV
- RFC3678_API
- ZEND_ENABLE_ZVAL_LONG64
- ZTS

Follow-up of GH-5526
2024-06-24 19:37:07 +02:00