Commit Graph

15984 Commits

Author SHA1 Message Date
Niels Dossche
daa94cf279
Implement request #30622: make $namespace parameter functional
This parameter never actually did anything and was forgotten about.
We solve this by detecting when we have a $namespace argument
(that won't conflict with the name argument) and creating a Clark
notation name out of it.

Closes GH-16123.
2024-09-30 20:34:51 +02:00
Niels Dossche
f5e81fe182
Optimize in-memory XMLWriter
We're currently using a libxml buffer, which requires copying the buffer
to zend_strings every time we want to output the string. Furthermore,
its use of the system allocator instead of ZendMM makes it not count
towards the memory_limit and hinders performance.

This patch adds a custom writer such that the strings are written to a
smart_str instance, using ZendMM for improved performance, and giving
the ability to not copy the string in the common case where flush has
empty set to true.

Closes GH-16120.
2024-09-30 20:30:03 +02:00
Niels Dossche
63e0b9ccbf
Fix #49169: SoapServer calls wrong function, although "SOAP action" header is correct
Although the original reproducer no longer exists, I was able to cook up
something similar.
The problem is that there are two ways ext-soap currently looks up
functions:
1) By matching the exact function name; but this doesn't work if the
   function name is not in the body.
2) By matching the parameter names.

Neither of these work when we don't have the function name in the body,
and when the parameter names are not unique. That's where we can use the
"SOAPAction" header to distinguish between different actions. This header
should be checked first and be matched against the "soapAction"
attribute in the WSDL. We keep the existing fallbacks such that the
chance of a BC break is minimized.
Note that since #49169 a potential target namespace is ignored right
now.

Closes GH-15970.
2024-09-30 20:14:34 +02:00
David Carlier
1da352c367
ext/pgsql: adding pg_close_stmt.
up to postgresql 17, when done with a prepared statement, we could
release it with DEALLOCATE sql command which is fine ; until we want
to implement a cache solution based on statement ids.

Since PostgreSQL 17, PQclosePrepared uses internally the `close` protocol
allowing to reuse the statement name while still freeing it.
Since the close protocol implementation had been added on libpq within
this release, no way to reimplement it.

close GH-14584
2024-09-29 16:26:35 +01:00
Guillaume Outters
68537fd9f4
Fix / implement GH-15287: add a lazy fetch to Pdo\PgSql
Make Pdo\PgSql accept Pdo::setAttribute(PDO::ATTR_PREFETCH, 0) to enter libpq's single row mode.
This avoids storing the whole result set in memory before being able to call the first fetch().

close GH-15750
2024-09-29 08:33:14 +01:00
David Carlier
d00dd2b4b5
ext/random: haiku supports arc4random api too.
close GH-16095
2024-09-28 13:20:14 +01:00
武田 憲太郎
7f5e96d030
ext/pdo_pgsql: Expanding COPY input from an array to an iterable
close GH-15893
2024-09-28 11:09:34 +01:00
Saki Takamachi
7bd0bcadaa
Prepare for PHP 8.4 2024-09-25 00:03:39 +09:00
Saki Takamachi
c5b258fedc
Fix GH-15968: Avoid converting objects to strings in operator calculations. (#16021) 2024-09-24 22:33:36 +09:00
Bob Weinand
654b787ee1
Add API to exempt function from being traced in JIT (#15559)
Internally accessible via zend_jit_blacklist_function / externally via opcache_jit_blacklist.
The functionality currently only affects tracing JIT, but may be extended to other JIT modes in future.
2024-09-24 14:20:38 +02:00
David Carlier
f35ad560b4
GH-12940 ext/pdo_pgsql: using PQclosePrepared to free statement resources.
PQclosePrepared allows the statement's name to be reused thus allowing
cache solutions to work properly ; whereas, for now, the `DEALLOCATE
<statement>` query is used which free entirely the statement's resources.

close GH-13316
2024-09-24 12:09:56 +01:00
Christoph M. Becker
f44250c418
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15980: Signed integer overflow in main/streams/streams.c
2024-09-24 12:35:06 +02:00
Christoph M. Becker
acee803e6a
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15980: Signed integer overflow in main/streams/streams.c
2024-09-24 12:33:17 +02:00
Christoph M. Becker
81916758ec
Fix GH-15980: Signed integer overflow in main/streams/streams.c
We need to avoid signed integer overflows which are undefined behavior.
We catch that, and set `offset` to `ZEND_LONG_MAX` (which is also the
largest value of `zend_off_t` on all platforms).  Of course, that seek
may fail, but even if it succeeds, the stream is no longer readable,
but that matches the current behavior for offsets near `ZEND_LONG_MAX`.

Closes GH-15989.
2024-09-24 12:32:00 +02:00
Ayesh Karunaratne
ba748e7bb5
ext/curl: Add CURLOPT_DEBUGFUNCTION option (GH-15674)
This adds support for `CURLOPT_DEBUGFUNCTION`[^1] Curl option to set a
custom callback that gets called with debug information during the
lifetime of a Curl request.

The callback gets called with the `CurlHandle` object, an integer
containing the type of the debug message, and a string containing the
debug message. The callback may get called multiple times with the
same message type during a request.

PHP already uses `CURLOPT_DEBUGFUNCTION` functionality to internally
to expose a Curl option named `CURLINFO_HEADER_OUT`.

However,`CURLINFO_HEADER_OUT` is not a "real" Curl option supported
by libcurl. Back in 2006, `CURLINFO_HEADER_OUT` was added[^2] as
a Curl option by using the debug-callback feature. Git history does
not run that back to show why `CURLINFO_HEADER_OUT` was added as a
Curl option, and why the other debug types (such as
`CURLINFO_HEADER_IN` were not added as Curl options, but this seems
to be a historical artifact when we added features without trying
to be close to libcurl options.

This approach has a few issues:

1. `CURLINFO_HEADER_OUT` is not an actual Curl option supported by
  upstream libcurl.

2. All of the Curl options have `CURLOPT_` prefix, and `CURLINFO_HEADER_OUT`
  is the only Curl "option" that uses the `CURLINFO` prefix. This exception
  is, however, noted[^3] in docs.

3. When `CURLINFO_HEADER_OUT` is set, the `CURLOPT_VERBOSE` is also implicitly
  set. This was reported[^4] to bugs.php.net, but the bug is marked as wontfix.

This commit adds support for `CURLOPT_DEBUGFUNCTION`. It extends the existing
`curl_debug` callback to store the header-in information if it encounters
a debug message with `CURLINFO_HEADER_OUT`. In all cases, if a callable
is set, it gets called.

`CURLOPT_DEBUGFUNCTION` intends to replace `CURLINFO_HEADER_OUT` Curl
option as a versatile alternative that can also be used to extract
other debug information such as SSL data, text information messages,
incoming headers, as well as headers sent out (which `CURLINFO_HEADER_OUT`
makes available).

The callables are allowed to throw exceptions, but the return values are
ignored.

`CURLOPT_DEBUGFUNCTION` requires `CURLOPT_VERBOSE` enabled, and setting
`CURLOPT_DEBUGFUNCTION` does _not_ implicitly enable `CURLOPT_VERBOSE`.

If the `CURLOPT_DEBUGFUNCTION` option is set, setting `CURLINFO_HEADER_OUT`
throws a `ValueError` exception. Setting `CURLOPT_DEBUGFUNCTION` _after_
enabling `CURLINFO_HEADER_OUT` is allowed. Technically, it is possible
for both functionality (calling user-provided callback _and_ storing
header-out data) is possible, setting `CURLINFO_HEADER_OUT` is not
allowed to encourage the use of `CURLOPT_DEBUGFUNCTION` function.

This commit also adds the rest of the `CURLINFO_` constants used as
the `type` integer value in `CURLOPT_DEBUGFUNCTION` callback.

---

[^1]: [cur.se - CURLOPT_DEBUGFUNCTION](https://curl.se/libcurl/c/CURLOPT_DEBUGFUNCTION.html)
[^2]: [`5f25d80`](5f25d80d10)
[^3]: [curl_setopt doc mentioning `CURLINFO_` prefix is intentional](https://www.php.net/manual/en/function.curl-setopt.php#:~:text=prefix%20is%20intentional)
[^4]: [bugs.php.net - `CURLOPT_VERBOSE` does not work with `CURLINFO_HEADER_OUT`](https://bugs.php.net/bug.php?id=65348)
2024-09-24 10:56:56 +02:00
Christoph M. Becker
8a5ada4e10
Merge branch 'PHP-8.3'
* PHP-8.3:
  Revert "Fix GH-15980: Signed integer overflow in main/streams/streams.c"
2024-09-23 01:33:57 +02:00
Christoph M. Becker
a9fcf498e3
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Revert "Fix GH-15980: Signed integer overflow in main/streams/streams.c"
2024-09-23 01:32:45 +02:00
Christoph M. Becker
ee95ee7216
Revert "Fix GH-15980: Signed integer overflow in main/streams/streams.c"
This reverts commit 6a04c79e41, since the
new test case apparently fails on 64bit Linux, so this needs closer
investigation.
2024-09-23 01:31:05 +02:00
Christoph M. Becker
10008fb6e8
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15980: Signed integer overflow in main/streams/streams.c
2024-09-23 00:30:29 +02:00
Christoph M. Becker
c701508e6b
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15980: Signed integer overflow in main/streams/streams.c
2024-09-23 00:29:15 +02:00
Christoph M. Becker
6a04c79e41
Fix GH-15980: Signed integer overflow in main/streams/streams.c
We need to avoid signed integer overflows which are undefined behavior.
We catch that, and set `offset` to `ZEND_LONG_MAX` (which is also the
largest value of `zend_off_t` on all platforms).  Of course, after such
a seek a stream is no longer readable, but that matches the current
behavior for offsets near `ZEND_LONG_MAX`.

Closes GH-15989.
2024-09-23 00:28:09 +02:00
Saki Takamachi
f6db576c31
[RFC] ext/bcmath: Added bcdivmod (#15740)
RFC: https://wiki.php.net/rfc/add_bcdivmod_to_bcmath

Added bcdivmod() function and added divmod() method to BcMath\Number class.
2024-09-23 06:43:11 +09:00
Christoph M. Becker
2b90acb469
Fix GH-15986: Double-free due to Pdo\Pgsql::setNoticeCallback()
We need to release the fcall info cache instead of destroying it.

Closes GH-15987.
2024-09-22 23:35:05 +02:00
Christoph M. Becker
8c407fc3d0
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix minimal Windows version
2024-09-22 19:30:03 +02:00
Christoph M. Becker
5bcbe8a358
Fix minimal Windows version
As of PHP 8.3.0, Windows 8/Server 2012 are the minimum requirement.
However, PR #9104 only updated `_WIN32_WINNT`, but not `WINVER`[1],
`NTDDI_VERSION`[2] nor the manifest[3].

[1] <https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers>
[2] <https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers>
[3] <https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests>

Closes GH-15975.
2024-09-22 19:28:43 +02:00
Christoph M. Becker
1d92796107
Merge branch 'PHP-8.3'
* PHP-8.3:
  Prevent closing of unrelated handles
2024-09-22 17:29:05 +02:00
Christoph M. Becker
ffc355c83f
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Prevent closing of unrelated handles
2024-09-22 17:26:34 +02:00
Christoph M. Becker
f303840a86
Prevent closing of unrelated handles
If our `shmget()` fails for certain reasons, the segment handle is
closed.  However, the handle might be reused by Windows, and as such we
must not close it again when shutting down the TSRM.

Closes GH-15984.
2024-09-22 17:24:01 +02:00
Niels Dossche
5bfd45cd44
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15908 and GH-15026: leak / assertion failure in streams.c
2024-09-22 16:09:21 +02:00
Niels Dossche
94c2ae616b
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15908 and GH-15026: leak / assertion failure in streams.c
2024-09-22 16:08:51 +02:00
Niels Dossche
018c0b3d14
Fix GH-15908 and GH-15026: leak / assertion failure in streams.c
This was first reported as a leak in GH-15026, but was mistakingly
believed to be a false positive. Then an assertion was added and it got
triggered in GH-15908. This fixes the leak. Upon merging into master the
assertion should be removed as well.

Closes GH-15924.
2024-09-22 16:07:12 +02:00
Niels Dossche
27b3131422
Fix GH-15982: Assertion failure with array_find when references are involved
Closes GH-15983.
2024-09-22 14:34:55 +02:00
Saki Takamachi
05cb27a8f9
ext/bcmath: Check for scale overflow (#15741) 2024-09-22 06:59:06 +09:00
Niels Dossche
1b171bb6b4
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15918: Assertion failure in ext/spl/spl_fixedarray.c
2024-09-20 17:34:54 +02:00
Niels Dossche
9774cedb01
Fix GH-15918: Assertion failure in ext/spl/spl_fixedarray.c
SplFixedArray should've never get supported in ArrayObject because it's
overloaded, and so that breaks assumptions. This regressed in c4ecd82f.

Closes GH-15947.
2024-09-20 17:34:23 +02:00
Remi Collet
090b53bc44
[ci skip] NEWS + UPGRADING 2024-09-19 15:36:26 +02:00
Ilija Tovilo
1b9568d354
Implement backed enum coercion in http_build_query()
Fixes GH-15650
Closes GH-15704
2024-09-19 00:27:09 +02:00
Christoph M. Becker
7a8767fe62
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15901: phpdbg: Assertion failure on `i funcs`
2024-09-18 23:51:45 +02:00
Christoph M. Becker
c76913fde0
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15901: phpdbg: Assertion failure on `i funcs`
2024-09-18 23:50:20 +02:00
Christoph M. Becker
422aa17b9b
Fix GH-15901: phpdbg: Assertion failure on i funcs
New hash tables are not automatically packed, so we must not treat them
as such.  Therefore we guard the foreach appropriately.

Closes GH-15929.
2024-09-18 23:48:31 +02:00
Niels Dossche
e2da65de2a
NEWS for 306dedcf5e
[ci skip]
2024-09-17 22:17:34 +02:00
Niels Dossche
c9a4abadcc
Fix unsetting DOM properties
This never did anything in lower versions, but on master this crashes
because the virtual properties don't have backing storage. Just forbid
it since it was useless to begin with.

Closes GH-15891.
2024-09-17 19:24:49 +02:00
Niels Dossche
31e2ec63d8
Fix GH-15923: GDB: Python Exception <class 'TypeError'>: exceptions must derive from BaseException
Triggers on release builds when printing data structures.
You can't raise a string, you must raise exceptions.

Closes GH-15928.
2024-09-17 19:24:18 +02:00
Juliette
4830535b69
[skip ci] PHP 8.4 NEWS: fix typos in parameter names (#15931)
Ref: PR 15362 / c818d944cf (diff-7ee66c4f1536ac84dc5bbff1b8312e2eef24b974b3e48a5c5c2bcfdf2eb8f3ce)

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
2024-09-17 16:47:08 +01:00
Ayesh Karunaratne
3afb96184e ext/mbstring: Update to Unicode 16
Updates UCD to Unicode 16.0 (released 2024 Sept).

Previously: 0fdffc18, #7502, #14680

Unicode 16 adds several new character sets and case folding rules.
However, the existing ucgendat script can still parse them.

This also adds a couple test cases to make sure the new rules for
East Asian Wide characters and case folding work correctly. These
tests fail on Unicode 15.1 and older because those verisons do not
contain those rules.
2024-09-17 10:40:00 +09:00
Ilija Tovilo
2fce0bb877
Implement ReflectionProperty::isFinal()
Closes GH-15919
2024-09-16 23:22:52 +02:00
Niels Dossche
1ce07b0957
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15711: SoapClient can't convert BackedEnum to scalar value
  Use get_serialization_string_from_zval() in all encoding functions
  Introduce get_serialization_string_from_zval() and use it in to_xml_string()
2024-09-16 20:51:34 +02:00
Niels Dossche
25289dd08e
Fix GH-15711: SoapClient can't convert BackedEnum to scalar value
Allow SoapClient to use the backing value during response serialization.

Closes GH-15803.
2024-09-16 20:47:36 +02:00
Niels Dossche
55aa5f3ffb
Fix GH-15910: Assertion failure in ext/dom/element.c 2024-09-16 20:06:07 +02:00
Ilija Tovilo
c7397f5131
[skip ci] Fix NEWS section 2024-09-16 14:34:19 +02:00