1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Commit Graph

142786 Commits

Author SHA1 Message Date
Volker Dusch
03c9d2303e Update versions for PHP 8.5.0beta3 php-8.5.0beta3 2025-09-09 13:09:59 +02:00
Tim Düsterhus
37bf0ec961 main: Deprecate deriving $_SERVER['argc'] and $_SERVER['argv'] from the query string (#19606)
* main: Ignore `register_argc_argv` when `SG(request_info).argc` is available

* sapi: Remove hardcoded `register_argc_argv` for CLI SAPIs

This INI is ignored since the previous commit, which makes the hardcoded
setting obsolete.

* main: Deprecate deriving $_SERVER['argc'] and $_SERVER['argv'] from the query string

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_register_argc_argv_ini_directive

* main: Adjust deprecation message for `register_argc_argv`

* NEWS/UPGRADING
2025-09-09 10:34:35 +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
5a177eedd5 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak when providing an invalid locale to IntlDateFormatter (#19764)
  Fix intl tests naming (#19763)
2025-09-09 08:42:34 +02:00
Alexandre Daubois
f9805eb14b Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix intl tests naming (#19763)
2025-09-09 08:42:10 +02:00
Alexandre Daubois
b718514dc2 Fix memory leak when providing an invalid locale to IntlDateFormatter (#19764) 2025-09-09 08:41:32 +02:00
Alexandre Daubois
9eedf00206 Fix intl tests naming (#19763) 2025-09-09 08:41:20 +02:00
Tim Düsterhus
4c04ff33c9 uri: Make the .free_uri handlers safe to call with NULL (#19627)
* uri: Make the `.free_uri` handlers safe to call with `NULL`

The `php_uri_free()` function already unconditionally called `->free_uri()` and
thus couldn't be safely used when the `->uri` was `NULL` for some reason.

The lexbor implementation was already safe, because `lxb_url_destroy()` is
guaranteed to be a noop for `NULL`.

* uri: Stop checking for `NULL` before calling `->free_uri()`

This implicitly fixes an `UNEXPECTED(…->uri != NULL)` in `uri_free_obj_handler`
that likely should have read `EXPECTED` instead.

* uri: Remove unnecessary reset of `->uri` to `NULL` in `php_uri_object_handler_free()`

* uri: Document the requirement of `free_uri()` being safe with `NULL`
2025-09-09 08:37:51 +02:00
Calvin Buckley
cebe50a1af Remove driver specific support from ODBC (#15727)
* Purge most special cases for building ODBC with specific drivers

PDO_ODBC doesn't do this, and most of these drivers are not in use with
PHP, at least like this. Chances are these expose an ODBC driver you can
use with a normal driver manager like unixODBC or iODBC. If not, it can
be specified as a custom driver, though it does not include any
workarounds.

There might be some redundant definitions now as a result.

IBM Db2 is kept as a special case due to it also being in PDO_ODBC,
though I wonder how good of an idea this is.

See GH-15630

* Remove never used include

This would only be used on 68k classic Mac OS. Did PHP ever run there?

* Fold HAVE_SQL_EXTENDED_FETCH

All supported driver managers can do extended fetches.

* Ope, accidentally deleted this in a refactor

* All driver managers support SQLDataSources now too

So we don't need the define?

* Remove undef CHAR

There's no justification behind as to why this should be.

* Don't special case SQL_TIMESTAMP

The default handling for turning into SQL_C_CHAR is fine, and the
special case for Adabas is no longer needed.

* Assume fetch_hash is always possible

The driver managers and even Db2 support this.

This would also allow simplifying the fetch code to merge fetch_into and
fetch_array into a single implementation perhaps.

* Update UPGRADING for driver specific removal

* Update NEWS for driver specific removal
2025-09-09 00:07:15 -03:00
Tim Düsterhus
156c847467 uri: Fix handling of the errors == NULL && !silent for uri_parser_whatwg (#19748)
* uri: Fix handling of the `errors == NULL && !silent` for uri_parser_whatwg

Previously, when `errors` was `NULL`, the `errors` pointer was used to set the
`$errors` property when throwing the exception, leading to a crash. Use a local
zval to pass the errors to the Exception and copy it into the `errors` input
when it is non-`NULL`.

* uri: Only pass the `errors` zval when interested in it in `php_uri_instantiate_uri()`

This is no longer necessary since the previous commit and also is a layering
violation, since `php_uri_instantiate_uri()` should not care how `parse_uri()`
works internally.

* uri: Use `ZVAL_EMPTY_ARRAY()` when no parsing errors are available

* uri: Avoid redundant refcounting in error handling of uri_parser_whatwg

* NEWS
2025-09-09 00:10:39 +02:00
Niels Dossche
79eca3f2bf Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-19752: Phar decompression with invalid extension can cause UAF
2025-09-08 23:11:07 +02:00
Niels Dossche
c395355728 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19752: Phar decompression with invalid extension can cause UAF
2025-09-08 23:11:01 +02:00
Niels Dossche
f6878b6ccf Fix GH-19752: Phar decompression with invalid extension can cause UAF
The rename code can error out prior to the reassignment of the filename,
which is why the test causes a crash.
The rename code can also error out at a later point,
which means it will have already assigned the new filename.
We detect in which case we are in and act accordingly.

Closes GH-19761.
2025-09-08 23:10:33 +02:00
Niels Dossche
1869eff6ee Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix OSS-Fuzz #385993744
2025-09-08 19:10:46 +02:00
Niels Dossche
89f2805905 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix OSS-Fuzz #385993744
2025-09-08 19:10:41 +02:00
Niels Dossche
ff84cb08ef Fix OSS-Fuzz #385993744
PSFS_FEED_ME is supposed to be returned when the filter did not receive
enough data and did not generate buckets for the output brigade.
The test generates buckets anyway on the output brigade, and the stream
layer did not handle that case causing a memory leak.
To solve this, discard any such buckets as it would conflict with the
status code returned by the filter. This keeps BC and solves the leak.

Closes GH-18972.
2025-09-08 19:10:22 +02:00
Niels Dossche
91be3e196a Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak on failure in phar_convert_to_other()
  Fix metadata leak when phar convert logic fails
2025-09-08 19:06:42 +02:00
Niels Dossche
10a2a2a368 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak on failure in phar_convert_to_other()
  Fix metadata leak when phar convert logic fails
2025-09-08 19:06:37 +02:00
Niels Dossche
98bb934685 Fix memory leak on failure in phar_convert_to_other()
Closes GH-19755.
2025-09-08 19:06:11 +02:00
Niels Dossche
c50b37d231 Fix metadata leak when phar convert logic fails
Closes GH-19756.
2025-09-08 19:05:47 +02:00
Alexandre Daubois
124540a29c Reorder intl NEWS entry 2025-09-08 16:41:43 +02:00
Alexandre Daubois
2d11f4d636 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-11952: better locale strings canonicalization for IntlDateFormatter and NumberFormatter (#19593)
2025-09-08 16:39:50 +02:00
Alexandre Daubois
cc4cfbf984 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-11952: better locale strings canonicalization for IntlDateFormatter and NumberFormatter (#19593)
2025-09-08 16:38:31 +02:00
Alexandre Daubois
6a2adcd8a4 Fix GH-11952: better locale strings canonicalization for IntlDateFormatter and NumberFormatter (#19593) 2025-09-08 16:36:27 +02:00
tekimen
ad75c26044 [RFC] Add a locale for grapheme case-insensitive functions (#18792)
* [RFC] Add a locale for grapheme case-insensitive functions

Co-authored-by: Gina Peter Banyard <girgias@php.net>
2025-09-08 23:07:06 +09:00
Alexandre Daubois
5ae8125993 Fix GH-16993: Fix filter_var_array to warn when validation filters are incorrectly combined with FILTER_NULL_ON_FAILURE flag (#19660) 2025-09-08 14:50:09 +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
4432083f38 uri: Improve safety of URI object initialization (#19648)
* uri: Inline implementation of `php_uri_implementation_set_object_handlers()`

There is no one time fits all solution to initialization of the object
handlers. A follow-up commit will use distinct `create_object` handlers for
each parser class.

Explicitly spelling out the handlers is a well-established pattern in php-src
and I don't see a reason to diverge from that with an intransparent helper
method.

* uri: Initialize the `.internal` field of `uri_object_t` immediately upon creation

This makes the objects much safer to use, since the `.parser` will always be
available and matching the object.

* uri: Remove `uri_parser_name` parameter of `uri_unserialize()`

The parser for a given object is already known from the object itself and
particularly must never change. Reassigning the value in `uri_unserialize()` is
just unsafe, especially since the existing `->uri` is freed with the destructor
of the reassigned parser.

Just rely on the `->parser` field being set to the correct value.

* uri: Remove the `uri_parser` parameter from `php_uri_instantiate_uri()`

Similarly to the previous change to `uri_unserialize()`, the `->parser` must
always match the object for the freeing to be safe.

Given that we expect to successfully parse URIs, we can eagerly initialize the
resulting URI object when using the `::parse()` methods and destruct it again
when parsing fails and `null` is returned instead. Calling the destructor is
safe, since `uri` will be `NULL`, which will result in a noop.

The `base_url_object` must also match the object that is currently being
constructed. Verify this using assertions matching the `->ce` and the
`->parser`.

* uri: Export the individual object handlers
2025-09-08 08:55:56 +02:00
Máté Kocsis
4e8058e776 Add support for Uri\Rfc3986\Uri withers (#19636)
Related to https://wiki.php.net/rfc/url_parsing_api
2025-09-08 02:30:44 +02:00
David CARLIER
9f8802c416 ext/pdo_pgsql: [RFC] Deprecate PGSQL_TRANSACTION_ constants. (#19594) 2025-09-07 19:47:20 +01:00
David Carlier
b697d1bcfa Merge branch 'PHP-8.4' 2025-09-07 18:19:21 +01:00
David Carlier
a0b7dab64b Merge branch 'PHP-8.3' into PHP-8.4 2025-09-07 18:19:08 +01:00
David Carlier
93865a4086 Fix GH-19578: imagefilledellipse underflow on width argument.
close GH-19579
2025-09-07 18:18:17 +01:00
Samuel Štancl
a09d919ce8 Implement GH-8967: Add PDO_SQLITE_ATTR_TRANSACTION_MODE (#19317)
This commit implements GH-8967.

SQLite supports multiple transaction modes. These include:
- DEFERRED (default) only acquires a lock when you start a read/write
- IMMEDIATE acquires a reserved lock
- EXCLUSIVE acquires an exclusive lock (stricter than immediate)

In WAL mode IMMEDIATE and EXCLUSIVE are identical.

One reason for wanting to specify a transaction mode is that SQLite
doesn't respect busy_timeout when a DEFERRED transaction tries to
upgrade a read lock to a write lock. Normally if you try to acquire a
lock and have busy_timeout configured, SQLite will wait for that period
until giving up and erroring out (SQLITE_BUSY). With DEFERRED, if you
have a transaction that first reads and there's a concurrent writer
while it's trying to upgrade to a write lock, you will immediately get
SQLITE_BUSY regardless of your busy_timeout.

Prior to this commit, the only available workarounds were:
- Using $pdo->exec("BEGIN IMMEDIATE TRANSACTION") instead of
  $pdo->beginTransaction()
- Doing a dummy write at the start of each transaction so you don't get
  stuck with a read lock

Both of those aren't very usable, especially in a framework context
where the user doesn't have complete control over how transactions are
started.

To address that, this commit adds four class constants to Pdo\Sqlite:
- ATTR_TRANSACTION_MODE -- a new attribute
- TRANSACTION_MODE_DEFERRED = 0
- TRANSACTION_MODE_IMMEDIATE = 1
- TRANSACTION_MODE_EXCLUSIVE = 2

These can be used as:
  $pdo->setAttribute(
    $pdo::ATTR_TRANSACTION_MODE,
    $pdo::TRANSACTION_MODE_IMMEDIATE
  );
2025-09-07 15:42:30 +02:00
Tim Düsterhus
c267652d69 uri: Do not copy the normalized URI when cloning RFC 3986 URIs (#19588)
* uri: Do not copy the normalized URI when cloning RFC 3986 URIs

The with-ers are not yet implemented for RFC 3986, the argument in the comment
however makes sense and the implementation did not match the comment.

* uri: Fix typo in comment in uri_parser_rfc3986.c

Co-authored-by: Máté Kocsis <kocsismate90@gmail.com>

---------

Co-authored-by: Máté Kocsis <kocsismate90@gmail.com>
2025-09-07 15:26:21 +02:00
Niels Dossche
b5817cc4c3 Remove pointless zval_ptr_dtor() calls in userspace stream handling (#19712)
These act on LONGs, so dtor'ing them is pointless.
2025-09-07 13:26:20 +02:00
Niels Dossche
110fae0628 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak in phar tar temporary file error handling code
2025-09-07 13:05:13 +02:00
Niels Dossche
3d52e925a1 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak in phar tar temporary file error handling code
2025-09-07 13:05:07 +02:00
Niels Dossche
2f162214e8 Fix memory leak in phar tar temporary file error handling code
Closes GH-19740.
2025-09-07 13:04:19 +02:00
Tim Düsterhus
b90ab8119e uri: Call the proper clone_obj handler in uri_write_component_ex() (#19649)
* uri: Call the proper `clone_obj` handler in `uri_write_component_ex()`

For external URI implementation it's possible that the `->clone_obj` handler
does not match `uri_clone_obj_handler()`. Use the handler of the object instead
of making assumptions.

* uri: Call `RETVAL_OBJ(new_object)` early in `uri_write_component_ex()`

This allows to remove some error handling logic.

* uri: Remove now-useless declaration of `uri_clone_obj_handler` from php_uri_common.h
2025-09-06 20:53:09 +02:00
George Wang
f171afae23 Merge branch 'PHP-8.4' 2025-09-06 12:50:25 -04:00
George Wang
1557bb81a9 Merge branch 'PHP-8.3' into PHP-8.4 2025-09-06 12:47:20 -04:00
George Wang
ebbed484fb update LiteSpeed API to V8.3 2025-09-06 12:46:56 -04:00
George Wang
aa3983b31b fix pipe detection for STDERR. 2025-09-06 12:44:54 -04:00
David Carlier
2a96af743e fix build warnings for Haiku.
especially linker warning about php binary having an executable stack.

cloe GH-19575
2025-09-06 14:06:10 +01:00
Niels Dossche
366a5a2b37 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-19706: dba stream resource mismanagement
2025-09-06 00:08:55 +02:00
Niels Dossche
f744c827a8 Fix GH-19706: dba stream resource mismanagement
This regressed in 8.4 when dba started mixing objects and resources
(streams).
The streams are first destroyed at a first step in shutdown, and in slow
shutdown then the symbol table is destroyed which destroys the dba
objects. The dba objects still use the streams but they have been
destroyed already, causing a UAF. Using dtor_obj instead of free_obj
would work around this but would cause issues like memory leaks because
dtor_obj may be skipped while free_obj may not be.
Instead, use the same solution as mysqlnd uses in that we fully manage
the stream lifecycle ourselves. This also avoids users from meddling
with the stream through get_resources().
This would be fixed 'automatically' in the future when we are using
objects for everything.

Closes GH-19710.
2025-09-06 00:08:15 +02:00
Niels Dossche
9d8f2a4f4d Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-19720: Assertion failure when error handler throws when accessing a deprecated constant
2025-09-06 00:01:52 +02:00
Niels Dossche
c58312462c Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19720: Assertion failure when error handler throws when accessing a deprecated constant
2025-09-06 00:01:13 +02:00
Niels Dossche
9d69ab91ab Fix GH-19720: Assertion failure when error handler throws when accessing a deprecated constant
When deprecation causes an exception, we should return NULL instead of
continuing.

Closes GH-19723.
2025-09-06 00:00:52 +02:00