1
0
mirror of https://github.com/php/php-src.git synced 2026-04-17 21:11:02 +02:00
Commit Graph

1187 Commits

Author SHA1 Message Date
Christoph M. Becker
8683d17619 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-7809: Cloning a faked SplFileInfo object may segfault
2021-12-23 23:15:02 +01:00
Christoph M. Becker
0ed39ed809 Fix GH-7809: Cloning a faked SplFileInfo object may segfault
While the `path` is not supposed to be `NULL` for normal operation, it
is possible to create `SplFileInfo` objects where that is the case, and
we must not follow the null pointer.

Closes GH-7814.
2021-12-23 23:10:51 +01:00
Christoph M. Becker
fd2a6d2360 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #75917: SplFileObject::seek broken with CSV flags
2021-12-06 19:03:13 +01:00
Christoph M. Becker
6f325104eb Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #75917: SplFileObject::seek broken with CSV flags
2021-12-06 19:02:32 +01:00
Aliaksandr Bystry
daf79e2d91 Fix #75917: SplFileObject::seek broken with CSV flags
Closes GH-7697.
2021-12-06 18:59:48 +01:00
Tyson Andre
032de9e001 Optimize SplObjectStorage native read/write/has/unset dimension handlers
This makes reading/writing with `$splObjectStorage[$offset]` shorthand twice as
fast as it was previously, and a bit faster than offsetGet/offsetSet instead of
(previously) much slower.

Call destructor after overriding old SplObjectStorage entry.
Previously, it was called before, which was possibly unsafe
if the destructor had side effects.

Add tests.

Closes GH-7695

Related to GH-7690

Check for ref in SplObjectStorage->__unserialize, check for ref.

SplObjectStorage->unserialize may be a different cause of references
for malformed inputs, so continue checking

In internally used methods, convert references to non-references if they're
found.
2021-11-30 09:09:12 -05:00
Nikita Popov
902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00
Nikita Popov
8a7f9a5c38 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed bug #81587
2021-11-04 10:38:59 +01:00
Nikita Popov
d7ad32649a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed bug #81587
2021-11-04 10:38:08 +01:00
Nikita Popov
4b9fbc6627 Fixed bug #81587
iterator_funcs_ptr may be null for Iterators with custom
get_iterator. Ideally MultipleIterator would make use of get_iterator,
but this would require a large implementation change.
2021-11-04 10:34:52 +01:00
Nikita Popov
ee510eed68 Deprecate partially supported callables
This deprecates all callables that are accepted by
call_user_func($callable) but not by $callable(). In particular:

    "self::method"
    "parent::method"
    "static::method"
    ["self", "method"]
    ["parent", "method"]
    ["static", "method"]
    ["Foo", "Bar::method"]
    [new Foo, "Bar::method"]

RFC: https://wiki.php.net/rfc/deprecate_partially_supported_callables

Closes GH-7446.
2021-10-22 10:15:24 +02:00
Christoph M. Becker
0f2cb418f5 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
2021-09-29 16:19:00 +02:00
Christoph M. Becker
96ac919957 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
2021-09-29 16:18:36 +02:00
Christoph M. Becker
ee5711de33 Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
We must not free the read line, if the `READ_AHEAD` flag is set.  This
also restores the expectations of SplFileObject_next_variation002.phpt.

Closes GH-7518.
2021-09-29 16:17:14 +02:00
Christoph M. Becker
9800845d43 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
2021-09-28 15:55:40 +02:00
Christoph M. Becker
e73cc7aea9 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
2021-09-28 15:55:11 +02:00
Christoph M. Becker
6154aa652d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
2021-09-28 15:52:58 +02:00
Christoph M. Becker
2d6684091f Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
We address the `::setSize(0)` case by setting `array->element = NULL`
and `array->size = 0` before we destroy the elements.

Co-authored-by: Tyson Andre <tyson.andre@uwaterloo.ca>

Closes GH-7503.
2021-09-28 15:48:53 +02:00
Nikita Popov
15bbf6f337 Automatically determine whether to reuse get_iterator()
Same as with the IteratorAggregate case, allow reusing get_iterator
if none of the Iterator methods are overridden. Drop the
REUSE_GET_ITERATOR flag that previously allowed ArrayIterator to
opt-in to unconditional get_iterator reuse, and drop the override
handling it did, in favor of the automated approach.
2021-09-24 15:11:26 +02:00
Nikita Popov
088e547802 Fix FileSystemIterator without SKIP_DOTS
There were two separate bugs here:
 * The get_iterator implementation did not match the Iterator
   implementation. In particular, get_iterator did not respect
   SKIP_DOTS.
 * The constructor did not honor an explicitly omitted SKIP_DOTS
   flag. It could still be unset through setFlags() though.
2021-09-24 14:40:46 +02:00
Nikita Popov
fbbbb4876b Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix leak when iterating uninitialized RecursiveIteratorIterator
2021-09-24 13:18:11 +02:00
Nikita Popov
eac65680ab Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix leak when iterating uninitialized RecursiveIteratorIterator
2021-09-24 13:18:00 +02:00
Nikita Popov
3adbafeef7 Fix leak when iterating uninitialized RecursiveIteratorIterator 2021-09-24 13:17:34 +02:00
George Peter Banyard
a51869a202 Fix test by using a format specifier for resource to int conversion
Surprised this worked for so long
2021-09-17 23:05:35 +01:00
Tyson Andre
082c5b8327 Merge branch 'PHP-8.1' 2021-09-13 21:32:21 -04:00
Tyson Andre
27976d7dc7 Merge branch 'PHP-8.0' into PHP-8.1 2021-09-13 21:18:56 -04:00
Tyson Andre
753645a6f8 Merge remote-tracking branch 'origin/PHP-7.4' into PHP-8.0 2021-09-13 21:00:53 -04:00
Tyson Andre
b053192a03 Fix #81429: Handle resizing in SplFixedArray::offsetSet (#7487)
offsetSet did not account for the fact that the array may no longer exist after
the field is overwritten. This fixes that.

Add test of resizing both to the empty array and a smaller array - there should
be no valgrind warnings with a proper fix.

Alternate approach to #7486 (described in https://bugs.php.net/bug.php?id=81429)
2021-09-13 20:59:06 -04:00
Nikita Popov
768265cd22 Fix some more CLEAN sections 2021-09-06 17:03:35 +02:00
Nikita Popov
2ffa70b97c Slightly clean up is_callable implementation
And adjust an error message to line up with the error message
used for $callable() in zend_execute.c.
2021-09-02 10:37:13 +02:00
Máté Kocsis
75a678a7e3 Declare tentative return types for Zend (#7251)
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 13:44:20 +02:00
Máté Kocsis
b3e0888129 Declare tentative return types in ext/spl - part 3 (#7239) 2021-07-16 12:09:05 +02:00
Nikita Popov
c2b29308ff Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix RecursiveIteratorIterator segfault for invalid aggregate
2021-07-15 13:11:39 +02:00
Nikita Popov
b9ae73eee9 Fix RecursiveIteratorIterator segfault for invalid aggregate
The code was assuming that the returned value is an object.
Reuse the logic from IteratorIterator.
2021-07-15 13:11:28 +02:00
Nikita Popov
f556a30b92 Narrow ArrayIterator::key() return type
This can only return string|int|null, not any key type.
2021-07-15 11:03:50 +02:00
Máté Kocsis
6d805ed275 Declare tentative return types for ext/spl - part 2
Closes GH-7235
2021-07-14 15:19:51 +02:00
Nikita Popov
42cb5b5fa8 Throw from MultipleIterator::key/current() for invalid iterator
Calling current()/key() on an invalid iterator is an error
condition. Throw instead of returning false.
2021-07-14 12:40:45 +02:00
Nikita Popov
58f3f751ca Throw from SplObjectStorage::current() for invalid iterator
Accessing key()/current() on an invalid iterator is an error
condition. Throw instead of returning null.
2021-07-14 12:34:39 +02:00
Máté Kocsis
c6357b804e Declare tentative return types for ext/spl - part 1 (#7115) 2021-07-13 13:04:45 +02:00
Nikita Popov
8a67dfd16b Ensure correct return type from SplFileObject::getCurrentLine()
This is necessary to maintain return type consistency once
tentative return types are added.
2021-07-06 14:32:39 +02:00
Nikita Popov
188b1d4c7c SplFileObject::fgetcsv(): Consistently return false on failure
Both the documentation and the stubs state that this method is
supposed to return false on failure. However, if the line read
(rather than the getcsv operation) fails, it would incorrectly
return null instead.
2021-07-06 14:24:26 +02:00
Nikita Popov
ac7a28189a Add initialization checks to DirectoryIterator methods 2021-07-06 13:08:53 +02:00
Nikita Popov
f7b1238f13 Handle out of order destruction of RecursiveIteratorIterator 2021-07-02 17:14:00 +02:00
Nikita Popov
c2a8934b86 Fix typo in RecursiveIteratorIterator get_gc handler 2021-07-02 16:11:48 +02:00
George Peter Banyard
e9e06279c1 Refactor SplFixedArray (#7168)
* Move spl_offset_convert_to_long() to spl_fixedarray.c

It is only used there, which explains its weird offset semantics

* Refactor SplFixedArray offset handling
- Implement warning for resource type
- Throw a proper TypeError instead of a RuntimeException

* Use a proper Error to signal that [] cannot be used with SplFixedArray

* Refactor SplFixedArray has_dimension helper

* Drop some ZPP tests
2021-06-18 15:22:52 +01:00
Nikita Popov
71fb83567f Fix bug #80945: Don't throw undefined array key warning in ArrayObject unset()
This makes the behavior of ArrayObject the same as far plain
arrays, which don't throw a warning when unsetting a key that
already doesn't exit.
2021-06-14 10:14:38 +02:00
Nikita Popov
805471e86b Fix bug #81112: Implement JsonSerializable for SplFixedArray
This returns an array for SplFixedArray JSON encoding, which
is more appropriate than an object with integer string keys.

Closes GH-7117.
2021-06-14 10:07:45 +02:00
Nikita Popov
39131219e8 Migrate more SKIPIF -> EXTENSIONS (#7139)
This is a mix of more automated and manual migration. It should remove all applicable extension_loaded() checks outside of skipif.inc files.
2021-06-11 12:58:44 +02:00
Nikita Popov
9c18138a71 Support GC for RecursiveIteratorIterator
And move its dtor_obj handler into free_obj, so that cycle leaks
get automatically detected.
2021-06-09 11:25:50 +02:00
Ayesh Karunaratne
b8e380ab09 Update deprecation message for incompatible float to int conversion
Updates the deprecation message for implicit incompatible float to int conversion from:

```
Implicit conversion from non-compatible float %.*H to int in %s on line %d
```

to

```
Implicit conversion from float %.*H to int loses precision in %s on line %d
```

Related: #6661
2021-06-07 14:36:11 +02:00