Commit graph

70503 commits

Author SHA1 Message Date
Niels Dossche
4aa8c2fe5d
dom: Remove unnecessary objmap ptr null checks (#19092) 2025-07-11 10:35:14 +02:00
Niels Dossche
e013b4a91e
Make cloning DOM node lists, maps, and collections fail
This never worked and creates a broken object,
and on master can cause a crash with foreach.
It makes no sense to fix a behaviour that never worked, block it
instead.

Closes GH-19089.
2025-07-11 10:34:25 +02:00
Niels Dossche
f6380e4a38
Merge branch 'PHP-8.4'
* PHP-8.4:
  ext/soap/php_http.c: Fix memory leak of header value
2025-07-10 22:32:58 +02:00
Niels Dossche
de7a212630
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/soap/php_http.c: Fix memory leak of header value
2025-07-10 22:32:52 +02:00
Gina Peter Banyard
85a49d4198
ext/soap/php_http.c: Fix memory leak of header value 2025-07-10 22:32:31 +02:00
Demon
974526b244
ext/gd: Drop useless and doubtful MSVC specific code (libgd/libgd@f1480ab) 2025-07-10 22:22:01 +02:00
Demon
12fa8c637f
ext/gd: Drop useless and doubtful MSVC specific code (libgd/libgd@f1480ab) 2025-07-10 22:13:29 +02:00
Demon
2be3aa86f0
Zend: fix undefined symbol 'execute_ex' on Windows ARM64 #19064; ext/gd: fix emmintrin.h not found on Windows ARM64 2025-07-10 22:13:29 +02:00
Niels Dossche
c4183fba00
Fix GH-19070: setlocale($type, NULL) should not be deprecated
This restores the old behaviour.

Closes GH-19071.
2025-07-10 22:01:16 +02:00
Calvin Buckley
0d584c32c5
pdo_odbc: Don't fetch 256 byte blocks for long columns (#10809)
* pdo_odbc: Don't fetch 256 byte blocks for long columns

Fetching 256 byte blocks can confuse some drivers with conversion
routines. That, and it seems to me the round trips to and from a
database could be a major performance impact.

Instead, we try to fetch all at once, and continue fetching if a
driver somehow has more for us.

This has been tested with a problematic case with the Db2i driver
with stateful MBCS encodings.

See GH-10733 for discussion about this and issues it can resolve.

* change to separate by 256 bytes, when C->fetched_len == SQL_NO_TOTAL

change to separate by 256 bytes, when C->fetched_len == SQL_NO_TOTAL

changed from 256 byte to 2048 byte buf block.

* Make long column buffer size single define

Could be configurable maybe, but best to avoid magic numbers even for a
compile-time constant.

* Use ZendMM page size minus zend_string overhead

Change recommended by Christoph.

Probably a little better performance wise I have to guess.

* [skip ci] Update comment to mention constant

* Update UPGRADING for PDO_ODBC change

mention GH issues in UPGRADING too

* Update NEWS for PDO_ODBC change

---------

Co-authored-by: SakiTakamachi <saki@sakiot.com>
2025-07-10 13:03:11 -03:00
DanielEScherzer
07f1cfd9b0
Deprecate producing output in a user output handler (#19067)
https://wiki.php.net/rfc/deprecations_php_8_4
2025-07-09 21:20:58 -07:00
Tim Düsterhus
b43a7ac0e7
Zend: Make EG(fake_scope) a const zend_class_entry* (#19060) 2025-07-09 11:55:53 +02:00
DanielEScherzer
d8577d9bfb
Deprecate returning non-string values from a user output handler (#18932)
https://wiki.php.net/rfc/deprecations_php_8_4
2025-07-07 14:31:13 -07: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
DanielEScherzer
45215d0e78
php_spl.c: fix typo in spl_classes() description [skip ci] 2025-07-07 12:33:36 -07:00
DanielEScherzer
9225cb45ac
Make zend_register_*_constant() functions return pointers, use them (#19029)
Have each of the specialized methods for registering a constant return a
pointer to the registered constant the same way that the generic
`zend_register_constant()` function does, and use those in the generated
arginfo files to avoid needing to search for a constant that was just
registered in order to add attributes to it.
2025-07-07 12:23:52 -07:00
Peter Kokot
d154c7253e
Autoconf: Move getlogin check for HAVE_GETLOGIN to ext/posix (#19058)
This check is related only to ext/posix so it's more clear to have it
defined when ext/posix is enabled.
2025-07-07 17:43:36 +02:00
Ilija Tovilo
1039cebb87
Merge branch 'PHP-8.4'
* PHP-8.4:
  [skip ci] Add missing zlib dep to phar compression test
2025-07-07 16:28:58 +02:00
Ilija Tovilo
74784a0d52
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Add missing zlib dep to phar compression test
2025-07-07 16:28:49 +02:00
Ilija Tovilo
faa78313d9
[skip ci] Add missing zlib dep to phar compression test 2025-07-07 16:28:18 +02:00
Dmitry Stogov
dd69b65638
Merge branch 'PHP-8.4'
* PHP-8.4:
  Update IR
2025-07-07 14:03:36 +03:00
Dmitry Stogov
e8ae27bf8a
Update IR
IR commit: af6dc83bcd91c3123f40efcdcbeba8794b9b2abf
2025-07-07 14:03:11 +03:00
Zheng Yu
b068ee307f
Fix unreachable code in URL output handler (#19056)
Since `ZSTR_LEN()` returns a `size_t` (unsigned integer), the value can only be either "not equal to 0" or "equal to 0". The third `else` branch was unreachable, making the `*handled_output = NULL;` assignment dead code.
2025-07-07 10:57:43 +01:00
Peter Kokot
c2af281c0c
Use <winsock2.h> instead of legacy <winsock.h> (#19037)
This also omits defining unused HAVE_WINSOCK_H macro when building
ext/sockets.
2025-07-07 09:40:03 +02:00
Tim Düsterhus
c1ed6088a6
uri: Do not overwrite defaultMemoryManager (#19042)
The `defaultMemoryManager` is only available via a non-public
header and is not supposed to be used by users of the library [1].
It also has a very generic name, further indicating that it is not
supposed to be used.

Instead pass the memory manager explicitly, which is how the library is
supposed to be used.

[1] https://github.com/uriparser/uriparser/issues/52#issuecomment-453853700
2025-07-06 20:48:14 +02:00
Gina Peter Banyard
22f2a1d47b ext/pcntl: Pack module globals struct
This saves 8 bytes
2025-07-06 18:24:38 +01:00
Gina Peter Banyard
3de6695ae8 ext/pcntl: Use uint8_t type for num_signals module global 2025-07-06 18:24:38 +01:00
Gina Peter Banyard
89e4de8d7b ext/pcntl: Use bool type for some module globals
This clarifies intention and uses less bytes in the struct
2025-07-06 18:24:38 +01:00
Gina Peter Banyard
36358bad84 ext/session: get rid of sname_len field
This is unnecessary now that the session name is a zend_string
2025-07-06 17:21:00 +01:00
Gina Peter Banyard
c3dac0f8b6 ext/session: Minor code cleanups 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
db01dbc4ee ext/session: Initialize variable with default value
To make it easier for IDEs to understand what is going on
2025-07-06 17:21:00 +01:00
Gina Peter Banyard
766ccc2210 ext/session: Use zend_string for some session globals 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
f5166b3bb6 ext/session: convert global session_name to zstr 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
b83484df97 ext/session: Use is_numeric_str helper 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
ac3807ee8d ext/session: Use ZEND_STRL() 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
c529e2f85b ext/session: Use smart_str_append when possible 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
eaee504c4d ext/session: Concert save_path to zstr 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
9c68853023 ext/session: copy zstr instead of initializing a new one 2025-07-06 17:21:00 +01:00
Gina Peter Banyard
43fe9fd171 ext/session: convert some globals to zend_string
This prevents some strlen computations
2025-07-06 17:21:00 +01:00
Gina Peter Banyard
677a1f80c8
ext/standard/stream: Use FCC instead of zval for notification callback (#19024)
Also check that the callable exists while setting the option
2025-07-06 01:30:07 +01:00
Niels Dossche
5a2a150829
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix phar crash and file corruption with SplFileObject
2025-07-05 21:44:39 +02:00
Niels Dossche
2aeefb13be
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix phar crash and file corruption with SplFileObject
2025-07-05 21:44:34 +02:00
Niels Dossche
405be1c940
Fix phar crash and file corruption with SplFileObject
There are two bugfixes here.
The first was a crash that I discovered while working on GH-19035.
The check for when a file pointer was still occupied was wrong, leading
to a UAF. Strangely, zip got this right.

The second issue was that even after fixing the first one, the file
contents were garbage. This is because the file write offset for the
phar stream was wrong.

Closes GH-19038.
2025-07-05 21:44:12 +02:00
Niels Dossche
4d27420543
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix stream double free in phar
2025-07-05 21:32:29 +02:00
Niels Dossche
50a5a6f315
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix stream double free in phar
2025-07-05 21:31:50 +02:00
Niels Dossche
32344c4dc4
Fix stream double free in phar
The copy function does two things wrong:
- The error recovery logic is a hack that temporarily moves the fp
  pointer to cfp, even though it's not compressed. The respective error
  recovery it talks about is not present in the code, nor is it
  necessary. This is the direct cause of the double free in the original
  reproducer. Fixing this makes it crash in another location though.
- The link following logic is inconsistent and illogical. It cannot be a
  link at this point.

The root cause, after fixing the above issues, is that the file pointers
are not reset properly for the copy. The file pointer need to be the
original ones to perform the copy from the right source, but after that
they need to be set properly to NULL (because fp_type == PHAR_FP).

Closes GH-19035.

Co-authored-by: Yun Dou <dixyes@gmail.com>
2025-07-05 21:31:28 +02:00
Máté Kocsis
5a9f5a6514
Add the Uri\Rfc3986\Uri class to ext/uri without wither support (#18836)
Relates to #14461 and https://wiki.php.net/rfc/url_parsing_api

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
2025-07-05 10:00:20 +02:00
DanielEScherzer
4e42ad5bf2
ext/standard/string.c: don't use STR_EMPTY_ALLOC() (#19033)
This was the only remaining use of a compatibility alias from 10 years ago;
replace with `ZSTR_EMPTY_ALLOC()`.
2025-07-04 14:41:24 -07:00
DanielEScherzer
d43fbc0c0e
ReflectionParameter::allowsNull() - fix typo in description [skip ci] 2025-07-04 12:33:48 -07:00
Máté Kocsis
8bb6b81c60
Update uriparser to commit 8c06d 2025-07-04 08:20:27 +02:00