1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 16:08:35 +02:00
Commit Graph

2528 Commits

Author SHA1 Message Date
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
Dmitry Stogov 5caf29a01e Switch few functions useful in Symphony apps to new ZPP API. 2021-02-24 19:13:11 +03:00
Dmitry Stogov 99d0f502dc Fixed error message 2021-02-24 19:12:32 +03:00
Cameron Porter 24e7299c9d Fixed bug #80724
FilesystemIterator::FOLLOW_SYMLINKS is currently treated as a directory
key mode flag, even though it does not change the way that the key
during iteration is set. To address this, FOLLOW_SYMLINKS has been
converted into an OTHER flag.

Closes GH-6695.
2021-02-23 09:50:36 +01:00
Máté Kocsis 4f4c031f62 Generate ext/spl class entries from stubs
Closes GH-6709
2021-02-18 13:01:51 +01:00
Nikita Popov 549235d327 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix leak when breaking out of FilesystemIterator
  Fixed bug #80600
2021-02-15 10:38:32 +01:00
Nikita Popov 8e9eeca0b3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix leak when breaking out of FilesystemIterator
2021-02-15 10:38:21 +01:00
Nikita Popov 44a80b64b9 Fix leak when breaking out of FilesystemIterator
We need to always destroy current, not just when iter.data is not
set.

Take this opportunity to clean up the iterator destructor code a
bit, to remove redundant checks and incorrect comments.
2021-02-15 10:37:59 +01:00
Nikita Popov b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

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

Closes GH-6475.
2021-02-11 21:46:13 +01:00
Nikita Popov f0b387d1e4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80719
2021-02-11 16:14:12 +01:00
Nikita Popov 226395a335 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80719
2021-02-11 16:13:56 +01:00
Nikita Popov c34c523467 Fixed bug #80719 2021-02-11 16:12:06 +01:00
Levi Morrison 18f9d6bb7e Sort some decls in spl_iterators.h
There are enough of them that sorting makes it a bit nicer.
2021-02-11 05:11:11 -07:00
Dmitry Stogov c83cbc52a0 Remove useless zend_update_class_constants() calls 2021-01-28 16:38:36 +03:00
Nikita Popov 0368dc9f28 Fix proptable canonicalization bypass in ArrayObject
When an ArrayObject wraps an object, we should be using the
proptable canonicalilzation rules, which require all keys to be
strings.
2021-01-26 14:05:41 +01:00
Máté Kocsis 1954e59758 Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
Nikita Popov a9efcb1561 gen_stub: Also verify implementation-alias
This makes --verify also check @implementation-alias. Failures are
ignored using @no-verify instead. Some mistakes have been made that
would have been caught by this...

Closes GH-6615.
2021-01-19 09:48:33 +01:00
Nikita Popov d340be0d32 Merge branch 'PHP-8.0'
* PHP-8.0:
  SplFileObject::fgets() cannot return false
2021-01-18 16:47:47 +01:00
Nikita Popov f2364f316d SplFileObject::fgets() cannot return false
spl_filesystem_file_read() is called with silent=0, so it will
throw on failure.
2021-01-18 16:47:21 +01:00
Nikita Popov 3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00