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

3020 Commits

Author SHA1 Message Date
Gina Peter Banyard
4d528531be ext/spl: extract AppendIterator constructor (#21367)
The implementation of it is simple whereas spl_dual_it_construct() is extremely convoluted
2026-03-21 17:05:33 +00:00
ndossche
a16ace8ee7 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-21454: Missing write lock validation in SplHeap
2026-03-17 08:47:51 +01:00
ndossche
c9a6743b59 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-21454: Missing write lock validation in SplHeap
2026-03-17 08:47:46 +01:00
ndossche
8796d75365 Fix GH-21454: Missing write lock validation in SplHeap
Closes GH-21448.
2026-03-17 08:47:20 +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
Arnaud Le Blanc
65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
Gina Peter Banyard
0f4fd2d03c ext/spl: use ZPP specifier that doesn't free trampoline for spl_autoload_unregister() 2026-01-20 20:54:38 +00:00
Gina Peter Banyard
ab2cd2d6b6 ext/spl: inline HT_MOVE_TAIL_TO_HEAD macro
This is used only once anyway
2026-01-20 20:54:38 +00:00
Gina Peter Banyard
8326ad029d ext/spl: refactor autoloading to use newer FCC APIs 2026-01-20 20:54:38 +00:00
Gina Peter Banyard
0cd648a42e ext/spl: refactor spl_autoload()
Remove unused parameter
Use zend_string_concat2() API
Use size_t for ext_len parameter type
Return bool instead of int
2026-01-20 20:54:38 +00:00
Gina Peter Banyard
2d10ae2f98 ext/spl: move autoloading tests to subfolder 2026-01-20 20:54:38 +00:00
Niels Dossche
d8d754fc31 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-20856: heap-use-after-free in SplDoublyLinkedList iterator when modifying during iteration
2026-01-11 20:43:19 +01:00
Niels Dossche
a82a93d64e Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-20856: heap-use-after-free in SplDoublyLinkedList iterator when modifying during iteration
2026-01-11 20:43:12 +01:00
Niels Dossche
2a2e0e8128 Fix GH-20856: heap-use-after-free in SplDoublyLinkedList iterator when modifying during iteration
The element may be still in use in other places, so the linking pointers
should be kept consistent. If not consistent, the "move forward" code in
the sample test will read a stale, dangling pointer.

Closes GH-20885.
2026-01-11 20:42:25 +01:00
Niels Dossche
9b0643ea36 spl: Remove unused fields from spl dllist (#20886) 2026-01-11 15:08:31 +01:00
David Carlier
ae59c69467 ext/spl: DirectoryIterator to support modern filesytems.
With filesystems with builtin large capacity such as ZFS, Btfrs, NTFS
 or even ext4 with large_dir feature enabled, an int to represent an
entry index is falling short, thus risking overflows.

A zend_long however should cover this need without  increasing out
internal data structure.

close GH-20705
2025-12-14 22:01:02 +00:00
Niels Dossche
1f648c3118 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix test for 8.5+
2025-12-14 13:35:08 +01:00
Niels Dossche
526938648e Fix test for 8.5+ 2025-12-14 13:35:03 +01:00
David Carlier
b8ee9bb032 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-20678: resource created by GlobIterator crashes with fclose().
2025-12-14 11:59:24 +00:00
David Carlier
4d680fa1e2 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-20678: resource created by GlobIterator crashes with fclose().
2025-12-14 11:59:14 +00:00
David Carlier
90475249dd Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-20678: resource created by GlobIterator crashes with fclose().
2025-12-14 11:58:41 +00:00
David Carlier
97a90f4361 Fix GH-20678: resource created by GlobIterator crashes with fclose().
close GH-20697
2025-12-14 11:58:18 +00:00
Niels Dossche
1848bcddfd Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-20614: SplFixedArray incorrectly handles references in deserialization
2025-11-30 10:43:52 +01:00
Niels Dossche
6afe2cef78 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-20614: SplFixedArray incorrectly handles references in deserialization
2025-11-30 10:43:27 +01:00
Niels Dossche
9734ba4d21 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-20614: SplFixedArray incorrectly handles references in deserialization
2025-11-30 10:42:19 +01:00
Niels Dossche
366ed4c750 Fix GH-20614: SplFixedArray incorrectly handles references in deserialization
All other code caters to dereferencing array elements, except the
unserialize handler. This causes references to be present in the fixed
array even though this seems not intentional as reference assign is
otherwise impossible.
On 8.5+ this causes an assertion failure. On 8.3+ this causes references
to be present where they shouldn't be.

Closes GH-20616.
2025-11-30 10:41:32 +01:00
Niels Dossche
dcac024bb0 spl: Avoid pointless copies for internal construction calls (#20610) 2025-11-29 11:21:24 +01:00
Tim Düsterhus
db8d35e7eb tree-wide: Replace ZEND_WRONG_PARAM_COUNT() by its definition (#20066)
* tree-wide: Replace `WRONG_PARAM_COUNT` by `ZEND_WRONG_PARAM_COUNT()`

This is a direct alias.

* tree-wide: Replace `ZEND_WRONG_PARAM_COUNT()` by its definition

This macro was hiding control flow (the return statement) and thus was
particularly unhygienic.
2025-11-12 21:28:56 +01:00
Alexandre Daubois
da238e7a11 ext/spl: convert zend_parse_parameters_none() to fast ZPP (#20441) 2025-11-10 23:31:58 +00:00
Gina Peter Banyard
0df31e5a5b Merge branch 'PHP-8.5'
* PHP-8.5:
  Update NEWS for null deprecation bug fix
  Fix GH-20194: null offset deprecation not emitted for writes (#20238)
2025-10-29 18:37:29 +00:00
Gina Peter Banyard
9a1b8a785d Fix GH-20194: null offset deprecation not emitted for writes (#20238)
Based on a patch from @ndossche
2025-10-29 18:36:10 +00:00
Niels Dossche
0583cce838 Merge branch 'PHP-8.5'
* PHP-8.5:
  Improve __unserialize() hardening for SplHeap/SplPriorityQueue
2025-10-11 23:52:47 +02:00
Niels Dossche
bc76b3fca9 Improve __unserialize() hardening for SplHeap/SplPriorityQueue
It was possible to make the heap accept unserialize data when the heap
was corrupted or under modification. This adds the necessary check to
prevent that from happening.
Also, the exception check at the bottom is pointless,
spl_heap_unserialize_internal_state() already returns FAILURE on
exception. If it *is* necessary, it should be documented why.

Closes GH-20109.
2025-10-11 23:52:37 +02:00
Niels Dossche
1c9e1d6049 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-20101: SplHeap/SplPriorityQueue serialization exposes INDIRECTs
2025-10-08 18:55:05 +02:00
Niels Dossche
0458b3c8db Fix GH-20101: SplHeap/SplPriorityQueue serialization exposes INDIRECTs
Exposing INDIRECTs to userland is not allowed and can lead to all sorts
of wrong behaviour. In this case it lead to UAF bugs.
Solve it by duplicating the properties table, which de-indirects the
elements and also decouples it for future modifications.

Closes GH-20102.
2025-10-08 18:54:45 +02:00
Jakub Zelenka
c07b9cc49d Merge branch 'PHP-8.5' 2025-10-06 10:32:28 +02:00
Nicolas Grekas
fc353966f3 Revert deprecation of __sleep and __wakeup (#19966) 2025-10-06 10:30:27 +02:00
Niels Dossche
57ce245e1e Reduce code bloat in arginfo by using specialised string releases (#20016)
* Reduce code bloat in arginfo by using specialised string releases

Comparing this patch to master (c7da728574),
with a plain configure command without any options:

```
   text	   data	    bss	    dec	    hex	filename
20683738	1592400	 137712	22413850	156021a	sapi/cli/php
20688522	1592400	 137712	22418634	15614ca	sapi/cli/php_old
```

We see a minor reduction of 0.023% in code size.

* Also use true for the other initialization line

* Also use specialized code for consts
2025-10-02 22:00:20 +02:00
Tim Düsterhus
7f1cc0ec32 spl: Use true / false instead of 1 / 0 for bool parameters
Changes done with Coccinelle:

    @r1@
    identifier F;
    identifier p;
    typedef bool;
    parameter list [n1] PL1;
    parameter list [n2] PL2;
    @@

    F(PL1, bool p, PL2) {
    ...
    }

    @r2@
    identifier r1.F;
    expression list [r1.n1] EL1;
    expression list [r1.n2] EL2;
    @@

    F(EL1,
    (
    - 1
    + true
    |
    - 0
    + false
    )
    , EL2)
2025-09-24 18:51:40 +02:00
Tim Düsterhus
60f8969f7d spl: Use return true / return false for functions returning bool
Changes done with Coccinelle:

    @r1@
    identifier fn;
    typedef bool;
    symbol false;
    symbol true;
    @@

    bool fn ( ... )
    {
    <...
    return
    (
    - 0
    + false
    |
    - 1
    + true
    )
    ;
    ...>
    }

Coccinelle patch sourced from
torvalds/linux@46b5c9b856.
2025-09-24 18:51:40 +02:00
Tim Düsterhus
15baf35cf0 spl: Use true / false instead of 1 / 0 when assigning to bool
Changes done with Coccinelle:

    @@
    bool b;
    @@

    - b = 0
    + b = false

    @@
    bool b;
    @@

    - b = 1
    + b = true
2025-09-24 18:51:40 +02:00
Alexandre Daubois
e6c07b004b Fix GH-14402: Add support for serialization in SplPriorityQueue, SplMinHeap and SplMaxHeap (#19447) 2025-09-22 09:43:09 +02:00
Gina Peter Banyard
a5f2eee785 Zend: Deprecate __wakeup() (#19435)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_sleep_and_wakeup_magic_methods
2025-09-11 06:57:21 +01:00
Alexandre Daubois
c1fa560ba9 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-19577: avoid integer overflow when using a small offset and PHP_INT_MAX with LimitIterator (#19585)
2025-09-05 08:10:48 +02:00
Alexandre Daubois
7cceda1597 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19577: avoid integer overflow when using a small offset and PHP_INT_MAX with LimitIterator (#19585)
2025-09-05 08:10:22 +02:00
Alexandre Daubois
05133ac962 Fix GH-19577: avoid integer overflow when using a small offset and PHP_INT_MAX with LimitIterator (#19585) 2025-09-05 08:09:06 +02:00
Alexandre Daubois
49e3956b70 core: Deprecate using null as an array offset and when calling array_key_exists() (#19511)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_using_values_null_as_an_array_offset_and_when_calling_array_key_exists
2025-09-04 22:12:24 +01:00
Alexandre Daubois
e5f81bd74c spl: Use size_t to store spl_heap’s count (#19482) 2025-08-15 09:50:49 +02:00
Gina Peter Banyard
fb87b14b6c ext/spl: Deprecate ArrayObject and ArrayIterator with objects (#19420)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_arrayobject_and_arrayiterator_with_objects

This also moves tests into a subfolder.
2025-08-14 12:38:57 +01:00
Gina Peter Banyard
16872310d5 ext/spl: Deprecate SplObjectStorage::contains(), SplObjectStorage::attach(), and SplObjectStorage::detach() (#19424)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_splobjectstoragecontains_splobjectstorageattach_and_splobjectstoragedetach
2025-08-09 11:36:14 +01:00