1
0
mirror of https://github.com/php/php-src.git synced 2026-04-04 06:32:49 +02:00
Commit Graph

2712 Commits

Author SHA1 Message Date
Dmitry Stogov
57a01e3a4a Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Keep original EG(jit_trace_num) value around __autoload()
2022-09-29 15:01:39 +03:00
Dmitry Stogov
f7d0a3e0e0 Keep original EG(jit_trace_num) value around __autoload() 2022-09-29 15:00:52 +03:00
Nikita Popov
70ad93dd6e Fix serialization of empty SplFixedArray
Avoid null pointer deref.
2022-09-15 22:36:19 +02:00
Bob Weinand
d1fc0017c9 Revert "Fix compilation on MacOS"
This reverts commit 800c6672e5.

Reverted along with a01dd9feda.
2022-09-14 11:28:06 +02:00
Bob Weinand
a01dd9feda Revert "Port all internally used classes to use default_object_handlers"
This reverts commit 94ee4f9834.

The commit was a bit too late to be included in PHP 8.2 RC1. Given it's a massive ABI break, we decide to postpone the change to PHP 8.3.
2022-09-14 11:13:23 +02:00
Bob Weinand
94ee4f9834 Port all internally used classes to use default_object_handlers
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-31 16:45:27 +02:00
Bob Weinand
800c6672e5 Fix compilation on MacOS
memrchr has an always available equivalent under the name of zend_memrchr.

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-31 16:45:27 +02:00
Tyson Andre
8b9679e88e Make var_export/debug_zval_dump check for infinite recursion on the *object* (#9448)
Switch the recursion check from the result of `get_properties_for`
(the returned hash table of properties) to just checking for
infinite recursion on the object.

- In order for a native datastructure to correctly implement
  `*get_properties_for` for var_export's cycle detection,
  it would need to return the exact same array every time prior to this PR.

  Prior to this commit, the requirements for cycle detection
  would prevent SplFixedArray or similar classes from returning a
  temporary array that:

  1. Wouldn't be affected by unexpected mutations from error handlers
  2. Could be garbage collected instead.
2022-08-30 09:19:45 -04:00
Máté Kocsis
adb45a63c0 Fix GH-9186 @strict-properties can be bypassed using unserialization (#9354)
* Emit deprecation warnings when adding dynamic properties to classes during unserialization - this will become an Error in php 9.0.
  (Adding dynamic properties in other contexts was already a deprecation warning - the use case of unserialization was overlooked)
* Throw an error when attempting to add a dynamic property to a `readonly` class when unserializing
* Add new serialization methods `__serialize`/`__unserialize` for SplFixedArray to avoid creating deprecated dynamic
  properties that would then be added to the backing fixed-size array
* Don't add named dynamic/declared properties (e.g. $obj->foo) of SplFixedArray to the backing array when unserializing
* Update tests to declare properties or to expect the deprecation warning
* Add news entry

Co-authored-by: Tyson Andre <tysonandre775@hotmail.com>
2022-08-30 07:46:32 -04:00
Máté Kocsis
bc4c012611 Declare ext/standard constants in stubs - part 1 (#9404) 2022-08-24 16:09:48 +02:00
Christoph M. Becker
a1f5c8a587 Fix GH-9227: Trailing dots and spaces in filenames are ignored
Given that Windows ignores trailing dots and spaces in filenames, we
catch that ourselves to avoid confusion with the respective filenames
without these characters.

Closes GH-9229.
2022-08-19 14:23:57 +02:00
Máté Kocsis
b73f139c70 Declare ext/spl constants in stubs (#9226) 2022-08-02 16:37:12 +02:00
George Peter Banyard
1478278f1d SPL: Use new improved is_line_empty() function instead of the old one (#9217) 2022-08-01 17:55:30 +01:00
George Peter Banyard
7ab22aad9e Refactor code handling file.current_zval (#8934)
The Zval is always an array
2022-07-28 19:36:30 +01:00
Jakub Zelenka
1a9e6895f1 Fix #65069: GlobIterator incorrect handling of open_basedir check
This PR changes the glob stream wrapper so it impacts "glob://"
streamsas well. The idea is to do a check for each found path instead
of the pattern which was not working correctly.
2022-07-28 11:42:42 +01:00
Christoph M. Becker
5d52d472ef Fix #69181: READ_CSV|DROP_NEW_LINE drops newlines within fields
One may argue that `DROP_NEW_LINE` does not make sense in combination
with `READ_CSV`, but without `DROP_NEW_LINE`, `SKIP_EMPTY` does not
skip empty lines at all.  We could fix that, but do not for BC reasons.
Instead we no longer drop newlines in `spl_filesystem_file_read_ex()`
when reading CSV, but handle that in `spl_filesystem_file_read_csv()`
by treating lines with only (CR)LF as being empty as well.

Closes GH-7618.
2022-07-26 18:33:57 +02:00
Ilija Tovilo
5c10aa43c2 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix spl test cleanup
2022-07-21 17:21:18 +02:00
Ilija Tovilo
3962f00b01 Fix spl test cleanup 2022-07-21 17:20:30 +02:00
Ilija Tovilo
b5ab0e06b8 Assert all test files are cleaned up in CI (#8977)
Closes GH-8427
2022-07-21 16:06:14 +01:00
George Peter Banyard
11c424c9fb Remove unnecessary include in SPL 2022-07-21 14:46:39 +01:00
Ilija Tovilo
d4a9cc8856 Fix rc info of iterator_to_array (#9080)
This function can now return a copy of the provided array, resulting in
a value of RC != 1.
2022-07-21 15:05:34 +02:00
Tim Düsterhus
7ae7df5b46 RFC: Make the iterator_*() family accept all iterables (#8819)
https://wiki.php.net/rfc/iterator_xyz_accept_array
2022-07-19 16:46:32 +02:00
Go Kudo
4d8dd8d258 Implement Random Extension
https://wiki.php.net/rfc/rng_extension
https://wiki.php.net/rfc/random_extension_improvement
2022-07-19 10:27:38 +01:00
Rowan Tommins
af15923bc3 Extend deprecation notices to is_callable($foo) and callable $foo
Implements https://wiki.php.net/rfc/partially-supported-callables-expand-deprecation-notices
so that uses of "self" and "parent" in is_callable() and callable
type constraints now raise a deprecation notice, independent of the
one raised when and if the callable is actually invoked.

A new flag is added to the existing check_flags parameter of
zend_is_callable / zend_is_callable_ex, for use in internal calls
that would otherwise repeat the notice multiple times. In particular,
arguments to internal function calls are checked first based on
arginfo, and then again during ZPP, so the former suppresses the
deprecation notice.

Some existing tests which raised this deprecation have been updated
to avoid the syntax, but the existing version retained for maximum
regression coverage until it is made an error.

With thanks to Juliette Reinders Folmer for the RFC and initial
investigation.

Closes GH-8823.
2022-07-14 17:07:42 +02:00
Arnaud Le Blanc
4df3dd7679 Reduce memory allocated by var_export, json_encode, serialize, and other (#8902)
smart_str uses an over-allocated string to optimize for append operations. Functions that use smart_str tend to return the over-allocated string directly. This results in unnecessary memory usage, especially for small strings.

The overhead can be up to 231 bytes for strings smaller than that, and 4095 for other strings. This can be avoided for strings smaller than `4096 - zend_string header size - 1` by reallocating the string.

This change introduces `smart_str_trim_to_size()`, and calls it in `smart_str_extract()`. Functions that use `smart_str` are updated to use `smart_str_extract()`.

Fixes GH-8896
2022-07-08 14:47:46 +02:00
George Peter Banyard
4ccf0b0181 Make php_fgetcsv() return a HashTale instead of in-out zval param (#8936)
Also refactor what happens on an empty line to return NULL instead of setting the array to [NULL] which makes no design sense at all.
However, as this is the current behaviour create a BC Shim inline function to recreate this weird HashTable in the functions which currently use this API
2022-07-08 12:11:05 +01:00
George Peter Banyard
247de8a4de Use true/false and comment when arg correspond to silent arg 2022-07-08 11:36:59 +01:00
George Peter Banyard
bb3d0933af Remove silent argument to spl_filesystem_file_read_line_ex()
true was always passed to it
2022-07-08 11:36:59 +01:00
George Peter Banyard
a055c54801 Remove silent argument to spl_filesystem_file_read_line()
true was always passed to it
2022-07-08 11:36:59 +01:00
George Peter Banyard
6f26102bbf Merge branch 'PHP-8.1'
* PHP-8.1:
  Revert "Fix GH-8563  Different results for seek() on SplFileObject and SplTempFileObject"
  Revert "Update FreeBSD CI image."
2022-07-05 21:45:13 +01:00
George Peter Banyard
e67336f46a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Revert "Fix GH-8563  Different results for seek() on SplFileObject and SplTempFileObject"
2022-07-05 21:33:47 +01:00
George Peter Banyard
79a283240e Revert "Fix GH-8563 Different results for seek() on SplFileObject and SplTempFileObject"
Although the fix is partially correct it also breaks long standing behaviour which has been produced since PHP 5.3.

This reverts commit 6f87a5c633.
2022-07-05 21:28:59 +01:00
David Carlier
dfbb425295 Use safe_*erealloc* flavor in few places to mitigate possible overflows. 2022-07-04 14:41:04 +01:00
George Peter Banyard
9bae9ab3a4 Fix GH-8861: correctly handle string lengths in SplFileinfo methods (#8869)
* Fix GH-8861: correctly handle string lengths in \SplFileinfo::getBasename

Co-authored-by: M. Vondano <m-vo@users.noreply.github.com>
2022-06-28 15:42:59 +01:00
Ilija Tovilo
3b92a96610 Convert return type of various object handlers from int to zend_result (#8755) 2022-06-26 01:00:19 +02:00
George Peter Banyard
20638dba3f Use the passed 'this' pointer instead of ZEND_THIS (#8854)
Removes the horrible hack usage of defining execute_data to be able to use ZEND_THING
2022-06-24 03:38:29 +01:00
George Peter Banyard
7cd8879d77 Refactor spl_filesystem_object_get_path() to return zend_string* 2022-06-23 14:41:24 +01:00
George Peter Banyard
623fbfe748 Remove Z_SPLFILESYSTEM_P macro
Remove one level of macro expansion hell
2022-06-23 14:41:24 +01:00
George Peter Banyard
4d43241e96 Move some private SPL Directory elements out of the header 2022-06-23 14:41:24 +01:00
George Peter Banyard
d5d0b07b4e Early return in spl_filesystem_file_rewind() 2022-06-20 17:27:35 +01:00
George Peter Banyard
a493c94471 Use bool for silent parameter in SPL directory.c 2022-06-20 17:27:25 +01:00
cmp
6bd0175173 Prevent fclose on underlying SplFileObject file stream. (#7920) 2022-06-20 13:37:59 +01:00
George Peter Banyard
8c50b8d797 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-8563  Different results for seek() on SplFileObject and SplTempFileObject
2022-06-20 12:53:26 +01:00
George Peter Banyard
080fde2605 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-8563  Different results for seek() on SplFileObject and SplTempFileObject
2022-06-20 12:53:01 +01:00
George Peter Banyard
6f87a5c633 Fix GH-8563 Different results for seek() on SplFileObject and SplTempFileObject
With memory streams if we get a NULL buffer we must not instantiate an empty line
2022-06-20 12:47:37 +01:00
Pierrick Charron
1bcd8d394a Update gen_stub to support #if around classes 2022-06-13 16:34:12 -04:00
George Peter Banyard
dbf1cafd77 Remove internal usage of SplFileInfo::_bad_state_ex() method (#8318)
* Use standard VM handling instead
 * Deprecate the method as it is now useless
2022-06-09 13:24:58 +01:00
George Peter Banyard
f800c60f13 Merge branch 'PHP-8.0' into PHP-8.1 2022-06-08 11:43:22 +01:00
George Peter Banyard
52eb52d652 Backport fcba0a49fc
Forgot this file exists in lower branches
2022-06-08 11:43:12 +01:00
George Peter Banyard
fcba0a49fc Fix test file name to not include a whitespace
This breaks the preload file flag in the test runner
2022-05-31 11:28:01 +01:00