1
0
mirror of https://github.com/php/php-src.git synced 2026-04-01 13:12:16 +02:00
Commit Graph

2547 Commits

Author SHA1 Message Date
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
George Peter Banyard
ff1145943f Refactor spl_array_has_dimension_ex()
Use early returns instead of else blocks
Add comments, especially to explain why we need a check_empty == 2 check
2021-06-18 00:47:04 +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
9d2a466c4b Remove explicit assignments of zend_objects_destroy_object
This is the default handler, no need to set it explicitly. This
makes it easier to see which objects really have a custom dtor_obj.
2021-06-09 11:29:50 +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
Nikita Popov
0643301c75 Don't perform recursive get_gc call
On further consideration, we should be making use of the fact
that zend_object_iterator is also a zend_object here, and let
GC handle the get_gc call on it. Calling get_gc recursively like
this is generally not safe, because there is only one gc_buffer.

This also happens to be much simpler...
2021-06-09 11:15:59 +02:00
Nikita Popov
67440dd695 Null out member after releasing
Missed this when changing from zval -> zend_string.
2021-06-09 10:52:27 +02:00
Nikita Popov
b2cf198733 Use zend_string* for RecursiveTreeIterator prefixes
We don't perform any append operations on these strings, they
are fixed. Use zend_string* rather than smart_str for them.
2021-06-09 10:49:59 +02:00
Nikita Popov
6b9ffaff56 Simplify string management in RecursiveTreeIterator
Make use of zend_string rather than zval to clean up the
implementation.
2021-06-09 10:38:58 +02:00
Nikita Popov
d7eea8e1be Store cached string as zend_string
This makes the code a bit simpler.
2021-06-09 10:15:36 +02:00
Nikita Popov
88c57df53d Remove dual_it dtor, add more GC roots
Move the dual_it_free call from the dtor_obj into the free_obj
handler, allowing us to drop the dtor_obj handler entirely. This
exposes another leak in bug65387.phpt, which is addressed by
adding more GC roots in the get_gc handler.
2021-06-09 10:04:43 +02:00
Nikita Popov
15fafcd664 Expose inner dual_it iterator to GC
Moving the zend_iterator_dtor from dual_it_dtor to dual_it_free_storage
exposed this GC leak in an existing test. Forward the result of the
iterator get_gc to the dual_it get_gc.
2021-06-08 16:55:22 +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
George Peter Banyard
b6958bb847 Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-31 15:48:45 +01:00
Anatol Belski
56c16334e5 ext: Cleanup some dead assignments
Signed-off-by: Anatol Belski <ab@php.net>
2021-05-29 13:03:32 +02:00
Nikita Popov
ea256a218b Add %0 format to run-tests.php
This format matches against null bytes, and prevents the test
expectation from being interpreted as binary data.

bless_tests.php will automatically replace \0 with %0 as well.
2021-05-29 11:33:13 +02:00
Nikita Popov
82ccd47d39 Use ZEND_TLS for spl (#7043)
For extension globals that do not require cross-module visibility, we can
use ZEND_TLS as a more efficient TLS mechanism.
2021-05-26 09:36:23 +02:00
Michael Voříšek
fd8770edef Remove randominess from spl_object_hash 2021-05-19 01:39:35 +01:00
Nikita Popov
11648c00e9 Don't include object hash in SplObjectStorage debug dump
The object hash is not particularly useful (anymore) and just
clutters the output. It encodes the same information as the
object ID, which is already part of the output.
2021-05-18 17:20:20 +02:00
George Peter Banyard
c757c61a8c Remove unnecessary error handler replacement in SPL
Document why it is needed in the remaining cases
Drive-by refactoring

Closes GH-6955
2021-05-07 11:17:56 +01:00
Nikita Popov
91dc10c906 Store SplFileObject open_mode as zend_string 2021-05-07 11:23:05 +02:00
Nikita Popov
9602db3b4a Fix open_mode for SplTempFileObject
open_mode was initialized to "wb", but the length set only to 1.
The effect of this was that the stream is opened using "wb", but
we only report "w".

Fix the length to report the actually used open_mode.
2021-05-07 11:18:51 +02:00
KsaR
01b3fc03c3 Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Máté Kocsis
a92f5cbe32 Use typed property in RegexIterator 2021-04-20 14:45:42 +02:00
Nikita Popov
71cbef78ba Fixed bug #80111
Remove traverse_pointer before destroying the element contents.
2021-04-19 14:41:19 +02:00
Nikita Popov
044de83635 Prefer ZVAL_COPY
Instead of ZVAL_COPY_VALUE + Z_TRY_ADDREF. Also fix another leak
in SplDoublyLinkedList::add(), the push case was leaking as well.
2021-04-19 14:35:36 +02:00
Nikita Popov
497fadcacd Fix leak in SplDoublyLinkedList::add() 2021-04-19 13:08:35 +02:00
Nikita Popov
02db708cd4 Remove generic dtor+ctor from SPL dllist
This is only ever used with zvals. It was particularly confusing
because a lot of code mixed the generic code with zval specific
code.
2021-04-19 13:02:19 +02:00
Christoph M. Becker
bebb0b7bbe Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
2021-04-13 16:50:15 +02:00
Christoph M. Becker
80f921d7e0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
2021-04-13 16:49:57 +02:00
Christoph M. Becker
976e71a2fa Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
`buf` may contain NUL bytes, so we must not use `strcspn()` but rather
a binary safe variant.  However, we also must not detect a stray CR as
line ending, and since we only need to check line endings at the end
of the buffer, we can nicely optimize.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6836.
2021-04-13 16:49:06 +02:00
K
3a05cda314 SplPriorityQueue performance improvements (#6859)
This optimization is targeting cases when a SplPriorityQueue instance is used
exclusively with double or long priorities.

During the first insertion into an empty queue, the comparator is changed to
the specialized one if the priority of inserted inserted key is long or double.
During insertion to non-empty queue, comparator is swapped back to the generic
one on type conflict.

As a result code like following, where the weight field is always double or
int, runs almost twice as fast.

foreach ($items as $item) {
  $pqueue->insert($item, -$item->weight);
  if ($pqueue->count() > $size) {
    $pqueue->extract();
  }
}
2021-04-12 20:39:34 +02:00
Dmitry Stogov
aeebed2a5b Use fast class cache 2021-04-12 14:52:05 +03:00
K
dc47b99391 SplHeap: replace zend_parse_parameters with ZEND_PARSE_PARAMETERS* macros
this change alone speeds up top-k computation significantly
2021-04-11 16:09:25 +02:00
Max Semenik
7f2f0c007c Migrate skip checks to --EXTENSIONS--, p4
For rationale, see #6787

Extensions migrated in part 4:
* simplexml
* skeleton
* soap
* spl
* sqlite3
* sysvmsg
* sysvsem
* tidy - also removed a check for an ancient dependency version
2021-04-08 10:36:44 +02:00
George Peter Banyard
5caaf40b43 Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Dmitry Stogov
46865392fe Attempt to fix ext/spl/tests/bug67359.phpt broken by f323baa845 2021-04-02 19:09:29 +03:00
Dmitry Stogov
93430e2b14 clear only neccessary part of spl_filesystem_object 2021-04-02 17:51:18 +03:00
Dmitry Stogov
f323baa845 Reduce number of stat() calls 2021-04-02 13:39:12 +03:00
Cameron Hall
5b29eba7ca Fix #42357: fputcsv() has an optional parameter for line endings
fputcsv does not terminate lines correctly as per RFC 41801[1]. After adding a new parameter fputcsv may now use a user defined line ending,. In order to maintain backwards compatibility fputcsv() still terminates lines with "\n" by default.

Also fixes: #46367[2], #62770[3]
Ref: #42357[4]

[1] <https://tools.ietf.org/html/rfc4180>
[2] <https://bugs.php.net/bug.php?id=46367>
[3] <https://bugs.php.net/bug.php?id=62770>
[4] <https://bugs.php.net/bug.php?id=42357>
2021-03-29 13:34:38 +01:00
Dmitry Stogov
c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Dmitry Stogov
1d5f359f56 Use spl_filesystem_object.file_name for SPL_FS_DIR as a cache and prevent multiple file name reconstruction. 2021-03-09 17:37:24 +03:00
Dmitry Stogov
16649cb60d Cache haschildren/getchildren methods of recursive iterators. 2021-03-04 17:04:55 +03:00
Dmitry Stogov
dd3bfb3704 Switch to new ZPP 2021-03-04 02:10:53 +03:00
Dmitry Stogov
c28751c69c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT)
2021-03-02 00:01:01 +03:00
Dmitry Stogov
957cb13a49 Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT) 2021-03-01 23:57:20 +03:00
Dmitry Stogov
17ad94df12 Optimize out zend_strpprintf() usage for simple concationaton 2021-02-26 10:34:30 +03:00
Dmitry Stogov
13e4ce386b Improve SPL directory and stat() cache using zend_srting* instead of char* 2021-02-26 02:28:46 +03:00